Use VPC endpoints - AWS CodeBuild (original) (raw)

You can improve the security of your builds by configuring AWS CodeBuild to use an interface VPC endpoint. Interface endpoints are powered by PrivateLink, a technology that you can use to privately access Amazon EC2 and CodeBuild by using private IP addresses. PrivateLink restricts all network traffic between your managed instances, CodeBuild, and Amazon EC2 to the Amazon network. (Managed instances don't have access to the internet.) Also, you don't need an internet gateway, NAT device, or virtual private gateway. You are not required to configure PrivateLink, but it's recommended. For more information about PrivateLink and VPC endpoints, see What is AWS PrivateLink?.

Before you create VPC endpoints

Before you configure VPC endpoints for AWS CodeBuild, be aware of the following restrictions and limitations.

Note

Use a NAT gateway if you want to use CodeBuild with AWS services that do not support Amazon VPC PrivateLink connections.

Create VPC endpoints for CodeBuild

Follow the instructions in Creating an interface endpoint to create the endpointcom.amazonaws.`region`.codebuild. This is a VPC endpoint for AWS CodeBuild.

The VPC endpoint configuration.

region represents the region identifier for an AWS Region supported by CodeBuild, such as us-east-2 for the US East (Ohio) Region. For a list of supported AWS Regions, see CodeBuild in the AWS General Reference. The endpoint is prepopulated with the Region you specified when you signed in to AWS. If you change your Region, the VPC endpoint is updated accordingly.

Create a VPC endpoint policy for CodeBuild

You can create a policy for Amazon VPC endpoints for AWS CodeBuild in which you can specify:

The following example policy specifies that all principals can only start and view builds for the project-name project.

{
    "Statement": [
        {
            "Action": [
                "codebuild:ListBuildsForProject",
                "codebuild:StartBuild",
                "codebuild:BatchGetBuilds"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:codebuild:region-ID:account-ID:project/project-name",
            "Principal": "*"
        }
    ]
}

For more information, see Controlling access to services with VPC endpoints in the Amazon VPC User Guide.