AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::CodeBuild::Project

The AWS::CodeBuild::Project resource configures how AWS CodeBuild builds your source code. For example, it tells AWS CodeBuild where to get the source code and which build environment to use.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::CodeBuild::Project", "Properties" : { "Artifacts" : Artifacts, "BadgeEnabled" : Boolean, "Cache" : ProjectCache, "Description" : String, "EncryptionKey" : String, "Environment" : Environment, "Name" : String, "LogsConfig" : LogsConfig, "SecondaryArtifacts" : [ Artifacts, ... ], "SecondarySources" : [ Source, ... ], "ServiceRole" : String, "Source" : Source, "Tags" : [ Resource Tag, ... ], "TimeoutInMinutes" : Integer, "Triggers" : Triggers, "VpcConfig" : VpcConfig } }

Properties

Artifacts

The output settings for artifacts that the project generates during a build.

Required: Yes

Type: AWS CodeBuild Project Artifacts

Update requires: No interruption

BadgeEnabled

Indicates whether AWS CodeBuild generates a publicly accessible URL for your project's build badge. For more information, see Build Badges Sample in the AWS CodeBuild User Guide.

Note

Including build badges with your project is currently not supported if the source type is AWS CodePipeline. If you specify CODEPIPELINE for the Source property, don't specify the BadgeEnabled property.

Required: No

Type: Boolean

Update requires: No interruption

Cache

Settings that AWS CodeBuild uses to store and reuse build dependencies.

Required: No

Type: AWS CodeBuild Project ProjectCache

Update requires: No interruption

Description

A description of the project. Use the description to identify the purpose of the project.

Required: No

Type: String

Update requires: No interruption

EncryptionKey

The alias or Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) that AWS CodeBuild uses to encrypt the build output. If you don't specify a value, AWS CodeBuild uses the AWS-managed CMK for Amazon Simple Storage Service.

Required: No

Type: String

Update requires: No interruption

Environment

The build environment settings for the project, such as the environment type or the environment variables to use for the build environment.

Required: Yes

Type: AWS CodeBuild Project Environment

Update requires: No interruption

LogsConfig

Information about logs for this build project.

Required: No

Type: AWS CodeBuild Project LogsConfig

Update requires: No interruption

Name

A name for the project. The name must be unique across all of the projects in your AWS account.

Required: Yes

Type: String

Update requires: Replacement

SecondaryArtifacts

An array of artifacts objects. Each artifacts object specifies output settings that the project generates during a build.

Required: No

Type: List of AWS CodeBuild Project Artifacts

Update requires: No interruption

SecondarySources

An array of source objects. Each source object contains source code settings for the project.

Required: No

Type: List of AWS CodeBuild Project Source

Update requires: No interruption

ServiceRole

The ARN of the service role that AWS CodeBuild uses to interact with services on your behalf.

Required: Yes

Type: String

Update requires: No interruption

Source

The source code settings for the project, such as the source code's repository type and location.

Required: Yes

Type: AWS CodeBuild Project Source

Update requires: No interruption

Tags

An arbitrary set of tags (key-value pairs) for the AWS CodeBuild project.

Required: No

Type: Resource Tag

Update requires: No interruption

TimeoutInMinutes

The number of minutes after which AWS CodeBuild stops the build if it's not complete. For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.

Required: No

Type: Integer

Update requires: No interruption

Triggers

For an existing AWS CodeBuild build project that has its source code stored in a GitHub repository, enables AWS CodeBuild to begin automatically rebuilding the source code every time a code change is pushed to the repository.

Required: No

Type: AWS CodeBuild Project ProjectTriggers

Update requires: No interruption

VpcConfig

Settings that enable AWS CodeBuild to access resources in an Amazon VPC. For more information, see Use AWS CodeBuild with Amazon Virtual Private Cloud in the AWS CodeBuild User Guide.

Required: No

Type: AWS CodeBuild Project VpcConfig

Update requires: No interruption

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the name of the AWS CodeBuild project, such as myProjectName.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. This section lists the available attribute and a sample return value.

Arn

The ARN of the AWS CodeBuild project, such as arn:aws:codebuild:us-west-2:123456789012:project/myProjectName.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Examples

The following example creates an AWS CodeBuild project.

JSON

{ "Project": { "Type": "AWS::CodeBuild::Project", "Properties": { "Name": "myProjectName", "Description": "A description about my project", "ServiceRole": { "Fn::GetAtt": [ "ServiceRole", "Arn" ] }, "Artifacts": { "Type": "no_artifacts" }, "Environment": { "Type": "LINUX_CONTAINER", "ComputeType": "BUILD_GENERAL1_SMALL", "Image": "aws/codebuild/java:openjdk-8", "EnvironmentVariables": [ { "Name": "varName", "Value": "varValue" } ] }, "Source": { "Location": "codebuild-demo-test/0123ab9a371ebf0187b0fe5614fbb72c", "Type": "S3" }, "TimeoutInMinutes": 10, "Tags": [ { "Key": "Key1", "Value": "Value1" }, { "Key": "Key2", "Value": "Value2" } ] } } }

YAML

Project: Type: AWS::CodeBuild::Project Properties: Name: myProjectName Description: A description about my project ServiceRole: !GetAtt ServiceRole.Arn Artifacts: Type: no_artifacts Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL Image: aws/codebuild/java:openjdk-8 EnvironmentVariables: - Name: varName Value: varValue Source: Location: codebuild-demo-test/0123ab9a371ebf0187b0fe5614fbb72c Type: S3 TimeoutInMinutes: 10 Tags: - Key: Key1 Value: Value1 - Key: Key2 Value: Value2

The following example creates a project that caches build dependencies in Amazon S3 and uses resources in an Amazon VPC.

JSON

{ "Resources": { "CodeBuildProject": { "Type": "AWS::CodeBuild::Project", "Properties": { "ServiceRole": { "Ref": "CodeBuildRole" }, "Artifacts": { "Type": "CODEPIPELINE" }, "Environment": { "Type": "LINUX_CONTAINER", "ComputeType": "BUILD_GENERAL1_SMALL", "Image": "aws/codebuild/ubuntu-base:14.04", "EnvironmentVariables": [ { "Name": "varName1", "Value": "varValue1" }, { "Name": "varName2", "Value": "varValue2", "Type": "PLAINTEXT" }, { "Name": "varName3", "Value": "/CodeBuild/testParameter", "Type": "PARAMETER_STORE" } ] }, "Source": { "Type": "CODEPIPELINE" }, "TimeoutInMinutes": 10, "VpcConfig": { "VpcId": { "Ref": "CodeBuildVPC" }, "Subnets": [ { "Ref": "CodeBuildSubnet" } ], "SecurityGroupIds": [ { "Ref": "CodeBuildSecurityGroup" } ] }, "Cache": { "Type": "S3", "Location": "mybucket/prefix" } } }, "CodeBuildRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": [ "sts:AssumeRole" ], "Effect": "Allow", "Principal": { "Service": [ "codebuild.amazonaws.com" ] } } ], "Version": "2012-10-17" }, "Path": "/", "Policies": [ { "PolicyName": "CodeBuildAccess", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": [ "logs:*", "ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DeleteNetworkInterface", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeDhcpOptions", "ec2:DescribeVpcs", "ec2:CreateNetworkInterfacePermission" ], "Effect": "Allow", "Resource": "*" } ] } } ] } }, "CodeBuildVPC": { "Type": "AWS::EC2::VPC", "Properties": { "CidrBlock": "10.0.0.0/16", "EnableDnsSupport": "true", "EnableDnsHostnames": "true", "Tags": [ { "Key": "name", "Value": "codebuild" } ] } }, "CodeBuildSubnet": { "Type": "AWS::EC2::Subnet", "Properties": { "VpcId": { "Ref": "CodeBuildVPC" }, "CidrBlock": "10.0.1.0/24" } }, "CodeBuildSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupName": "Codebuild Internet Group", "GroupDescription": "CodeBuild SecurityGroup", "VpcId": { "Ref": "CodeBuildVPC" } } } } }

YAML

Resources: CodeBuildProject: Type: AWS::CodeBuild::Project Properties: ServiceRole: !Ref CodeBuildRole Artifacts: Type: CODEPIPELINE Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL Image: aws/codebuild/ubuntu-base:14.04 EnvironmentVariables: - Name: varName1 Value: varValue1 - Name: varName2 Value: varValue2 Type: PLAINTEXT - Name: varName3 Value: /CodeBuild/testParameter Type: PARAMETER_STORE Source: Type: CODEPIPELINE TimeoutInMinutes: 10 VpcConfig: VpcId: !Ref CodeBuildVPC Subnets: [!Ref CodeBuildSubnet] SecurityGroupIds: [!Ref CodeBuildSecurityGroup] Cache: Type: S3 Location: mybucket/prefix CodeBuildRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - Action: ['sts:AssumeRole'] Effect: Allow Principal: Service: [codebuild.amazonaws.com] Version: '2012-10-17' Path: / Policies: - PolicyName: CodeBuildAccess PolicyDocument: Version: '2012-10-17' Statement: - Action: - 'logs:*' - 'ec2:CreateNetworkInterface' - 'ec2:DescribeNetworkInterfaces' - 'ec2:DeleteNetworkInterface' - 'ec2:DescribeSubnets' - 'ec2:DescribeSecurityGroups' - 'ec2:DescribeDhcpOptions' - 'ec2:DescribeVpcs' - 'ec2:CreateNetworkInterfacePermission' Effect: Allow Resource: '*' CodeBuildVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsSupport: 'true' EnableDnsHostnames: 'true' Tags: - Key: name Value: codebuild CodeBuildSubnet: Type: AWS::EC2::Subnet Properties: VpcId: Ref: CodeBuildVPC CidrBlock: 10.0.1.0/24 CodeBuildSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupName: Codebuild Internet Group GroupDescription: 'CodeBuild SecurityGroup' VpcId: !Ref CodeBuildVPC

See Also