Overview of managing access permissions to your Amazon CodeBuild resources - Amazon CodeBuild
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Overview of managing access permissions to your Amazon CodeBuild resources

Every Amazon resource is owned by an Amazon account, and permissions to create or access a resource are governed by permissions policies. An account administrator can attach permissions policies to IAM identities (that is, users, groups, and roles).


An account administrator (or administrator user) is a user with administrator privileges. For more information, see IAM Best Practices in the IAM User Guide.

When you grant permissions, you decide who is getting the permissions, the resources they can access, and the actions that can be performed on those resources.

Amazon CodeBuild resources and operations

In Amazon CodeBuild, the primary resource is a build project. In a policy, you use an Amazon Resource Name (ARN) to identify the resource the policy applies to. Builds are also resources and have ARNs associated with them. For more information, see Amazon Resource Names (ARN) and Amazon Service Namespaces in the Amazon Web Services General Reference.

Resource type ARN format
Build project




Report group arn:aws:codebuild:region-ID:account-ID:report-group/report-group-name
Report arn:aws:codebuild:region-ID:account-ID:report/report-ID

All CodeBuild resources


All CodeBuild resources owned by the specified account in the specified Amazon Region



Most Amazon services treat a colon (:) or a forward slash (/) as the same character in ARNs. However, CodeBuild uses an exact match in resource patterns and rules. Be sure to use the correct characters when you create event patterns so that they match the ARN syntax in the resource.

For example, you can indicate a specific build project (myBuildProject) in your statement using its ARN as follows:

"Resource": "arn:aws:codebuild:us-east-2:123456789012:project/myBuildProject"

To specify all resources, or if an API action does not support ARNs, use the wildcard character (*) in the Resource element as follows:

"Resource": "*"

Some CodeBuild API actions accept multiple resources (for example, BatchGetProjects). To specify multiple resources in a single statement, separate their ARNs with commas, as follows:

"Resource": [ "arn:aws:codebuild:us-east-2:123456789012:project/myBuildProject", "arn:aws:codebuild:us-east-2:123456789012:project/myOtherBuildProject" ]

CodeBuild provides a set of operations to work with the CodeBuild resources. For a list, see Amazon CodeBuild permissions reference.

Understanding resource ownership

The Amazon account owns the resources that are created in the account, regardless of who created the resources. Specifically, the resource owner is the Amazon account of the principal entity (that is, the root account, an user, or an IAM role) that authenticates the resource creation request. The following examples illustrate how this works:

  • If you use the root account credentials of your Amazon account to create a rule, your Amazon account is the owner of the CodeBuild resource.

  • If you create an user in your Amazon account and grant permissions to create CodeBuild resources to that user, the user can create CodeBuild resources. However, your Amazon account, to which the user belongs, owns the CodeBuild resources.

  • If you create an IAM role in your Amazon account with permissions to create CodeBuild resources, anyone who can assume the role can create CodeBuild resources. Your Amazon account, to which the role belongs, owns the CodeBuild resources.

Managing access to resources

A permissions policy describes who has access to which resources.


This section discusses the use of IAM in Amazon CodeBuild. It doesn't provide detailed information about the IAM service. For complete IAM documentation, see What Is IAM? in the IAM User Guide. For information about IAM policy syntax and descriptions, see Amazon IAM Policy Reference in the IAM User Guide.

Policies attached to an IAM identity are referred to as identity-based policies (IAM policies). Policies attached to a resource are referred to as resource-based policies. CodeBuild supports identity-based policies, and resource-based policies for certain read only APIs for the purpose of cross-account resource sharing.

Secure access to S3 buckets

We strongly recommend that you include the following permissions in your IAM role to verify the S3 bucket associated with your CodeBuild project is owned by you or someone you trust. These permissions are not included in Amazon managed policies and roles. You must add them yourself.

  • s3:GetBucketAcl

  • s3:GetBucketLocation

If the owner of an S3 bucket used by your project changes, you must verify you still own the bucket and update permissions in your IAM role if not. For more information, see Add CodeBuild access permissions to an IAM group or user and Create a CodeBuild service role.

Specifying policy elements: Actions, effects, and principals

For each Amazon CodeBuild resource, the service defines a set of API operations. To grant permissions for these API operations, CodeBuild defines a set of actions that you can specify in a policy. Some API operations can require permissions for more than one action in order to perform the API operation. For more information, see Amazon CodeBuild resources and operations and Amazon CodeBuild permissions reference.

The following are the basic policy elements:

  • Resource – You use an Amazon Resource Name (ARN) to identify the resource that the policy applies to.

  • Action – You use action keywords to identify resource operations you want to allow or deny. For example, the codebuild:CreateProject permission gives the user permissions to perform the CreateProject operation.

  • Effect – You specify the effect, either allow or deny, when the user requests the action. If you don't explicitly grant access to (allow) a resource, access is implicitly denied. You can also explicitly deny access to a resource. You might do this to make sure a user cannot access a resource, even if a different policy grants access.

  • Principal – In identity-based policies (IAM policies), the user the policy is attached to is the implicit principal. For resource-based policies, you specify the user, account, service, or other entity that you want to receive permissions.

To learn more about IAM policy syntax and descriptions, see Amazon IAM Policy Reference in the IAM User Guide.

For a table showing all of the CodeBuild API actions and the resources they apply to, see the Amazon CodeBuild permissions reference.