Skip to content

ella-adeka/Continuous-Integration-Pipeline

Repository files navigation

CONTINUOUS INTEGRATION PIPELINE

Set up a CI/CD pipeline using AWS CodePipeline, AWS CodeBuild, and AWS CodeDeploy. Create a sample application code repository on AWS CodeCommit or Github. Configure the pipeline to automatically build, test, and deploy the application to an EC2 instance or AWS Lambda function.

SERVICES

- CodePipeline: Release Software using Continuous Delivery
- CodeBuild: Build and Test Code
- CodeDeploy: Automate Code Deployments
- CodeCommit: Store Code in Private Git Repositories
* CodeStar: Quickly develop, build, and deploy applications

USE CASES FOR THE SERVICES

- Source: CodeCommit
- Artifacts: CodeArtifact
- Build: CodeBuild
- Deploy: CodeDeploy
- Pipeline: CodePipeline

STEPS

  1. Configure IAM Credentials

    • Navigate to IAM > Users
    • Select a user
    • Scroll down to the Permissions tab
      • Search for "AWSCodeBuildAdminAccess"
      • if present, proceed to the next step, if not:
        • Click Add Permission
          • Attach policies directly
          • Search for "AWSCodeBuildAdminAccess"
          • Select, and click Next
          • Review
          • Add permissions
    • Navigate to Security credentials tab
      • Scroll down to "HTTPS Git credentials for AWS CodeCommit"
      • Click generate credentials
      • Download your generated credentials and keep them safe
  2. Create Repository

    • Navigate to CodeCommit
      • Create a repository
      • Enter repo name as "CI_pipeline_project"
      • Enter the project description as description
      • Create
  3. Commit your code

    • Navigate into your repository by clicking on it
    • Once in, click "Add file" > Upload file
    • Choose file
    • Under "Commit changes to main"
      • Include the following:
        • Author name
        • Email address
        • Commit message
    • Commit changes
    • changes committed
  4. Launch an EC2 Instance

    • Navigate to EC2
    • Launch Instance
    • Enter "CIPipelineInstance" as the name
    • Choose Instance type as "t2.micro"
    • Create new key pair "CIPipelineMasterkey"
    • Configure Network
    • Add user data
    • Launch instance
  5. Create CodeDeploy Role

    • Navigate to IAM > Roles
    • Create Role
    • Select trusted entity
      • Select "AWS Service" as Trusted entity type
      • Enter CodeDeploy as Service or use case
      • Choose CodeDeploy as use case
      • Click Next#
    • Add premissions
      • Ensure policy name is set to "AWSCodeDeployRole"
      • Click Next
    • Name, review, and create
      • Role details
      • Enter "CodeDeployRole" as Role Name
      • Description is autogenerated by the role or enter "Allows CodeDeploy to call AWS services such as Auto Scaling on your behalf."
    • Create Role
  6. Deploy

    • Navigate to CodeDeploy
    • Applications
    • Create Application
      • Enter "CIPipelineApplication" as Application Name
      • Select "EC2/on-premises" as Compute platform
      • Create Application
    • In your application, navigate to "Deployment Groups" tab
      • Create Deployment group
      • Enter "CIPipelineDeploymentGroup" as Deployment Group name
      • Choose "CodeDeployRole" as a service role
      • Set Deployment type as "in place"
      • Choose "Amazon EC2 instances" as Environment configuration
        • In Tag group 1
          • Key: Name
          • Value: CIPipelineInstance ( or your instance name)
      • Load balancing
        • uncheck "Enable load balancing"
      • Create deployment group
  7. Build Project

    • On the left menu, navigate to Build > Build Projects
    • Create build project
    • Enter "CIPipelineBuild" as Project name
    • Source
      • Ensure Source provider is "AWS CodeCommit"
      • Choose "CI_pipeline_project" as Repository
      • Branch as reference type
      • Choose "main" as branch
    • Environment
      • Use "Managed image" as Environment image (since it is autogenerated by CodeBuild)
      • Operating System, Choose "Amazon Linux 2"
      • For Runtime(s), choose "Standard"
      • Choose "aws/codebuild/amazonlinux2-x86_64-standard:5.0" as Image
      • In Service role, leave New service role selected, and leave Role name unchanged.
    • Buildspec
      • Choose "Use a buildspec file"
    • Create build project
  8. Write buildspec.yml

  9. Code Pipeline

    • On the left menu, navigate to Pipeline > pipelines
    • Create Pipeline
    • Choose pipeline settings
      • Enter "CIPipeline" as pipeline name
      • Service role is created newly and autogenerated
      • Click Next
    • Add source stage
      • Choose CodeCommit as source
      • Choose "CI_pipeline_project" as Repository Name
      • Choose "main" as Branch name
      • Choose AWS CodePipeline as Amazon CloudWatch Events (recommended)
      • Click Next
    • Add build stage
      • Choose CodeBuild as Build provider
      • Choose "CIPipelineBuild" as Project Name
      • No need to add Environment variables (since none were set)
      • Choose "Single build" as build type
    • Add deploy stage
      • Choose "CodeDeploy" as Deploy provider
      • Choose "CIPipelineApplication" as Application Name
      • Choose "CIPipelineDeploymentGroup" as Deployment Group
    • Review
    • Create Pipeline

https://community.opengroup.org/osdu/platform/system/sdks/common-python-sdk/-/blob/86cfe1e16d577572363a34146b6f491ce0b60070/build-aws/buildspec.yaml

OVERALL DEPLOYMENT FAILED https://stackoverflow.com/questions/38195823/error-the-overall-deployment-failed-because-too-many-individual-instances-faile

CI/CD Pipeline on AWS https://www.youtube.com/watch?v=C99ps_cWp9Y&t=1430s

About

A CI/CD pipeline using AWS CodeCommit, AWS CodePipeline, AWS CodeBuild, and AWS CodeDeploy.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published