Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use CodeBuild condition keys as IAM service role variables to control build access

Focus mode
Use CodeBuild condition keys as IAM service role variables to control build access - AWS CodeBuild

With the CodeBuild build ARN, you can restrict build resource access by using context keys to scope down resource access in your CodeBuild service role. For CodeBuild, the keys that can be used to control build access behavior are codebuild:buildArn and codebuild:projectArn. With the build project ARN, you can verify whether a call to your resource came from a specific build project. To verify this, use the codebuild:buildArn or codebuild:projectArn condition keys in an IAM identity-based policy.

To use the codebuild:buildArn or codebuild:projectArn condition keys in your policy, include it as a condition with any of the ARN condition operators. The value of the key must be an IAM variable that resolves to a valid ARN. In the example policy below, the only access allowed will be to the build project with the project ARN for the ${codebuild:projectArn} IAM variable.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": "s3:PutObject", "Resource": "arn:aws:s3:::bucket-name/${codebuild:projectArn}/*" } }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.