AWS Code Pipeline

Some of our clients deploy applications using CodePipeline and CodeBuild.

Common Resources

In the infrastructure repository, create a root module for common CI/CD resources:

infra/ cicd-common/

In order to deploy CI/CD pipelines on AWS, you will need the following:

These resources should be provisioned in the Operations account.

After adding these modules to your root module, apply the module. Once the module has completed successfully, you will need to sign into the AWS Management Console. Find the pending GitHub connection and follow the instructions in the AWS Developer Tools Console User Guide to complete the connection.

Continuous Integration

For each application repository, create CodeBuild projects to build Docker images and generate manifests. These projects can be triggered when pull requests are opened using webhooks. Build projects and related resources should be provisioned in the Operations account.

infra/ ci/ APPLICATION/

In order to build Docker images for an application, you'll need:

Once this root module is applied, CodeBuild will start building and storing Docker images for your application whenever developers open pull requests.

Continuous Deployment

For each stage of the software development lifecycle, create a CodePipeline pipeline to deploy the latest images and manifests to the cluster. This pipeline can be triggered when pull requests are merged using webhooks. Pipelines should be provisioned in the Operations account.

infra/ cd/ APPLICATION/
  • An IAM role for deploying to each cluster. You can create one using the deploy role Terraform module. This role must be provisioned in the same Workload account as the cluster.

  • A buildspec for applying manifests to the cluster. You can use kubectl and other commands to apply the manifests generated by your manifests project.

  • A CodeBuild project for applying manifests to the cluster. You can set one up using the deploy-project Terraform module.

  • A CodePipeline pipeline for deploying the latest Docker images and manifests to the cluster. You can create pipelines using the cicd-pipeline Terraform module.

Once a pipeline is provisioned, the CodeBuild projects for building Docker images and manifests will be triggered whenever a pull request is merged. The artifacts from the manifest project will be provided to the deploy project, which can apply the manifests to the cluster.