CodeBuild projects should have artifact encryption enabled
CodeBuild artifacts often contain compiled binaries, packaged containers, or bundled application code that may embed secrets, API keys, or proprietary logic. When artifact encryption is disabled, these outputs are written to S3 in plaintext, exposing them to anyone with bucket-level read access.
Default behavior in CodeBuild encrypts artifacts with the AWS-managed S3 key (aws/s3). Explicitly setting encryption_disabled = true overrides that default and is almost never intentional. Catching this misconfiguration early prevents accidental data exposure in CI/CD pipelines.
Retrofit consideration
Enabling encryption on an existing project does not re-encrypt previously stored unencrypted artifacts. You must re-run builds or manually copy objects with encryption to remediate historical outputs.
Implementation
Choose the approach that matches how you manage Terraform.
Use AWS provider resources directly. See docs for the resources involved: aws_codebuild_project.
resource "aws_codebuild_project" "this" {
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/amazonlinux2-x86_64-standard:5.0"
type = "LINUX_CONTAINER"
}
logs_config {
cloudwatch_logs {
status = "ENABLED"
}
}
name = "pofix-abc123"
service_role = "arn:aws:iam::123456789012:role/example-role"
source {
buildspec = "version: 0.2\nphases:\n build:\n commands:\n - echo hello"
type = "NO_SOURCE"
}
artifacts {
encryption_disabled = false
location = "example-bucket-abc123"
type = "S3"
}
}
What this control checks
In the aws_codebuild_project resource, the artifacts block accepts an encryption_disabled argument that defaults to false, so artifacts are encrypted unless you explicitly override it. The control fails when encryption_disabled is set to true. The same check applies to every entry in the secondary_artifacts block: encryption_disabled must be false or omitted there as well. To pass, omit the argument entirely or set encryption_disabled = false in both artifacts and every secondary_artifacts block. To use a customer-managed key instead of the default aws/s3 key, set encryption_key at the top level of the aws_codebuild_project resource to the KMS key ARN.
Common pitfalls
Artifact type NO_ARTIFACTS still evaluated
When
artifacts.typeisNO_ARTIFACTS, theencryption_disabledargument can still appear in Terraform state, and some scanning tools will flag it even though no artifacts are produced. Omit the argument or setencryption_disabled = falseto avoid false positives.Secondary artifacts often overlooked
A single secondary artifact with
encryption_disabled = truefails the entire project. Thesecondary_artifactsblock gets less scrutiny during code review, and each entry carries its ownencryption_disabledflag independent of the primaryartifactsblock. Review every secondary artifact block, not just the primary.encryption_key vs encryption_disabled confusion
Setting
encryption_keyon theaws_codebuild_projectresource controls which KMS key to use. It does not overrideencryption_disabled = trueon individual artifact blocks. The two settings are independent: you must setencryption_disabled = falseeven when a customencryption_keyis configured.Terraform import may surface hidden defaults
Importing an existing CodeBuild project with
terraform importcan causeencryption_disabledto appear explicitly asfalsein state. If your HCL omits it, a spurious plan diff shows up. Pinencryption_disabled = falseexplicitly to keep plans clean.
Audit evidence
Auditors expect Config rule evaluation results showing all CodeBuild projects evaluated as compliant, or equivalent findings from a CSPM tool. Supporting evidence includes the BatchGetProjects API response showing encryptionDisabled: false for the artifacts and secondaryArtifacts fields across all projects in scope.
For stronger assurance, provide the KMS key policy governing artifact encryption and CloudTrail logs showing kms:GenerateDataKey calls tied to CodeBuild build executions, confirming encryption is active at runtime.
Framework-specific interpretation
PCI DSS v4.0: Requirement 3 covers protection of stored account data. If build artifacts can contain account data, disabling encryption on those outputs directly increases cardholder data risk. A customer-managed KMS key can support the key-management practices Requirement 3.6 calls for, but this control is one part of meeting Requirement 3, not a complete answer: broader data classification, scope definition, and key-management controls are also required.
Related controls
Tool mappings
Use these identifiers to cross-reference this control across tools, reports, and evidence.
Compliance.tf Control:
codebuild_project_artifact_encryption_enabledAWS Config Managed Rule:
CODEBUILD_PROJECT_ARTIFACT_ENCRYPTIONCheckov Check:
CKV_AWS_78Powerpipe Control:
aws_compliance.control.codebuild_project_artifact_encryption_enabledTrivy Check:
AWS-0018
Last reviewed: 2026-03-09