AWS CodeBuild¶
AWS CodeBuild can be used as a standalone service when running Uplift. This guide assumes CodeBuild was configured manually through the AWS Console and focuses on the gotchas1.
CodeBuild will always receive a git clone with a detached HEAD. By default, Uplift will error in this scenario. When performing a release, this will need to be resolved through a git checkout
. The CODEBUILD_SOURCE_VERSION
variable contains the necessary git reference.
IAM¶
Additional permissions are needed to pull and push code within AWS CodeBuild. These vary based on the SCM used.
Principle of Least Privilege
For illustration purposes, a resource type of "*"
is used. This should always be narrowed to the specific resource when possible.
CodeCommit¶
The codecommit:GitPush
IAM permission needs to be added. By default, the associated service role will already have the codecommit:GitPull
permission.
GitHub¶
Permissions are granted through the AWS Connector for GitHub
OAuth application from the AWS Console.
Buildspec¶
The buildspec can change depending on the base image used by the CodeBuild project.
Amazon Images¶
Tested against the Amazon Linux 2, Ubuntu and Windows variants.
- Without this Uplift will lack any credentials when attempting to push code back to the source SCM.
- This can be simplified to
git checkout $CODEBUILD_SOURCE_VERSION
when cloning from GitHub directly
Official Uplift Image¶
Tested against the public gembaadvantage/uplift
image.
Dealing with DockerHub Rate Limits
There are known issues with accessing public DockerHub repositories from AWS services, documented here.
Clone Depth¶
While configuring a CodeBuild project, the clone depth can be specified. For simplicity, a full clone should be used. If a shallow clone is preferred, you may need to fetch all tags by using the --fetch-all
flag.