Description
CodeBuild’s encryption_key selects the KMS key for build output artifacts. When omitted, the default is the AWS managed key for Amazon S3.
Potential impact
The default key may fall short of a requirement to manage the key policy and lifecycle yourself.
Remediation
If you need a customer managed key, choose one the service role can use. For CodePipeline artifacts, check the pipeline artifact store’s key as well. Configure log and environment-variable protection separately.
Examples
Both tasks use CODEPIPELINE. The explicit alias/aws/s3 in the second is also AWS managed. Supply the build environment and pipeline, then check the effective key on an output artifact.
Before
yaml
- name: My project
community.aws.codebuild_project:
name: my_project
description: My nice little project v2
service_role: arn:aws:iam::123456789012:role/service-role/code-build-service-role
source:
type: CODEPIPELINE
buildspec: ''
artifacts:
type: CODEPIPELINE
name: my_project
region: us-east-1
state: present
After
yaml
- name: My project
community.aws.codebuild_project:
name: my_project
description: My nice little project
service_role: arn:aws:iam::123456789012:role/service-role/code-build-service-role
source:
type: CODEPIPELINE
buildspec: ''
artifacts:
type: CODEPIPELINE
name: my_project
encryption_key: arn:aws:kms:us-east-1:123456789012:alias/aws/s3
region: us-east-1
state: present