Description
On a CodeBuild project, EncryptionKey chooses the key for encrypted output artifacts. When omitted, CodeBuild uses the AWS managed KMS key for Amazon S3.
Potential impact
The default key may fall short of requirements for separate key control. An unavailable key or missing permissions can prevent artifacts from being stored or read.
Remediation
If you need to control key policy and lifecycle, specify an approved key ARN or alias. Check the service role’s and consumers’ S3 and KMS permissions, then run a build and read the output. Review any option that disables artifact encryption, and check cache and log destinations separately.
Examples
Supply the S3 artifact bucket, CodeBuildRole, build environment and source settings.
Before
Resources:
BuildProject:
Type: AWS::CodeBuild::Project
Properties:
Name: my-build
ServiceRole: !GetAtt CodeBuildRole.Arn
Artifacts:
Type: S3
Location: !Ref ArtifactBucketName
After
Resources:
BuildProject:
Type: AWS::CodeBuild::Project
Properties:
Name: my-build
EncryptionKey: !Ref ArtifactKeyArn
ServiceRole: !GetAtt CodeBuildRole.Arn
Artifacts:
Type: S3
Location: !Ref ArtifactBucketName
The second project selects ArtifactKeyArn. Verify that the output artifact uses that key.