Class Project
Provides a CodeBuild Project resource. See also the aws.codebuild.Webhook resource, which manages the webhook to the source (e.g. the "rebuild every time a code change is pushed" option in the CodeBuild web console).
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleBucket = new Aws.S3.Bucket("exampleBucket", new Aws.S3.BucketArgs
{
Acl = "private",
});
var exampleRole = new Aws.Iam.Role("exampleRole", new Aws.Iam.RoleArgs
{
AssumeRolePolicy = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
""Effect"": ""Allow"",
""Principal"": {
""Service"": ""codebuild.amazonaws.com""
},
""Action"": ""sts:AssumeRole""
}
]
}
",
});
var exampleRolePolicy = new Aws.Iam.RolePolicy("exampleRolePolicy", new Aws.Iam.RolePolicyArgs
{
Policy = Output.Tuple(exampleBucket.Arn, exampleBucket.Arn).Apply(values =>
{
var exampleBucketArn = values.Item1;
var exampleBucketArn1 = values.Item2;
return @$"{{
""Version"": ""2012-10-17"",
""Statement"": [
{{
""Effect"": ""Allow"",
""Resource"": [
""*""
],
""Action"": [
""logs:CreateLogGroup"",
""logs:CreateLogStream"",
""logs:PutLogEvents""
]
}},
{{
""Effect"": ""Allow"",
""Action"": [
""ec2:CreateNetworkInterface"",
""ec2:DescribeDhcpOptions"",
""ec2:DescribeNetworkInterfaces"",
""ec2:DeleteNetworkInterface"",
""ec2:DescribeSubnets"",
""ec2:DescribeSecurityGroups"",
""ec2:DescribeVpcs""
],
""Resource"": ""*""
}},
{{
""Effect"": ""Allow"",
""Action"": [
""ec2:CreateNetworkInterfacePermission""
],
""Resource"": [
""arn:aws:ec2:us-east-1:123456789012:network-interface/*""
],
""Condition"": {{
""StringEquals"": {{
""ec2:Subnet"": [
""{aws_subnet.Example1.Arn}"",
""{aws_subnet.Example2.Arn}""
],
""ec2:AuthorizedService"": ""codebuild.amazonaws.com""
}}
}}
}},
{{
""Effect"": ""Allow"",
""Action"": [
""s3:*""
],
""Resource"": [
""{exampleBucketArn}"",
""{exampleBucketArn1}/*""
]
}}
]
}}
";
}),
Role = exampleRole.Name,
});
var exampleProject = new Aws.CodeBuild.Project("exampleProject", new Aws.CodeBuild.ProjectArgs
{
Artifacts = new Aws.CodeBuild.Inputs.ProjectArtifactsArgs
{
Type = "NO_ARTIFACTS",
},
BuildTimeout = "5",
Cache = new Aws.CodeBuild.Inputs.ProjectCacheArgs
{
Location = exampleBucket.BucketName,
Type = "S3",
},
Description = "test_codebuild_project",
Environment = new Aws.CodeBuild.Inputs.ProjectEnvironmentArgs
{
ComputeType = "BUILD_GENERAL1_SMALL",
EnvironmentVariable =
{
{
{ "name", "SOME_KEY1" },
{ "value", "SOME_VALUE1" },
},
{
{ "name", "SOME_KEY2" },
{ "type", "PARAMETER_STORE" },
{ "value", "SOME_VALUE2" },
},
},
Image = "aws/codebuild/standard:1.0",
ImagePullCredentialsType = "CODEBUILD",
Type = "LINUX_CONTAINER",
},
LogsConfig = new Aws.CodeBuild.Inputs.ProjectLogsConfigArgs
{
CloudwatchLogs = new Aws.CodeBuild.Inputs.ProjectLogsConfigCloudwatchLogsArgs
{
GroupName = "log-group",
StreamName = "log-stream",
},
S3Logs = new Aws.CodeBuild.Inputs.ProjectLogsConfigS3LogsArgs
{
Location = exampleBucket.Id.Apply(id => $"{id}/build-log"),
Status = "ENABLED",
},
},
ServiceRole = exampleRole.Arn,
Source = new Aws.CodeBuild.Inputs.ProjectSourceArgs
{
GitCloneDepth = 1,
GitSubmodulesConfig = new Aws.CodeBuild.Inputs.ProjectSourceGitSubmodulesConfigArgs
{
FetchSubmodules = true,
},
Location = "https://github.com/mitchellh/packer.git",
Type = "GITHUB",
},
SourceVersion = "master",
Tags =
{
{ "Environment", "Test" },
},
VpcConfig = new Aws.CodeBuild.Inputs.ProjectVpcConfigArgs
{
SecurityGroupIds =
{
aws_security_group.Example1.Id,
aws_security_group.Example2.Id,
},
Subnets =
{
aws_subnet.Example1.Id,
aws_subnet.Example2.Id,
},
VpcId = aws_vpc.Example.Id,
},
});
var project_with_cache = new Aws.CodeBuild.Project("project-with-cache", new Aws.CodeBuild.ProjectArgs
{
Artifacts = new Aws.CodeBuild.Inputs.ProjectArtifactsArgs
{
Type = "NO_ARTIFACTS",
},
BuildTimeout = "5",
Cache = new Aws.CodeBuild.Inputs.ProjectCacheArgs
{
Modes =
{
"LOCAL_DOCKER_LAYER_CACHE",
"LOCAL_SOURCE_CACHE",
},
Type = "LOCAL",
},
Description = "test_codebuild_project_cache",
Environment = new Aws.CodeBuild.Inputs.ProjectEnvironmentArgs
{
ComputeType = "BUILD_GENERAL1_SMALL",
EnvironmentVariable =
{
{
{ "name", "SOME_KEY1" },
{ "value", "SOME_VALUE1" },
},
},
Image = "aws/codebuild/standard:1.0",
ImagePullCredentialsType = "CODEBUILD",
Type = "LINUX_CONTAINER",
},
QueuedTimeout = "5",
ServiceRole = exampleRole.Arn,
Source = new Aws.CodeBuild.Inputs.ProjectSourceArgs
{
GitCloneDepth = 1,
Location = "https://github.com/mitchellh/packer.git",
Type = "GITHUB",
},
Tags =
{
{ "Environment", "Test" },
},
});
}
}
Inherited Members
Namespace: Pulumi.Aws.CodeBuild
Assembly: Pulumi.Aws.dll
Syntax
public class Project : CustomResource
Constructors
View SourceProject(String, ProjectArgs, CustomResourceOptions)
Create a Project resource with the given unique name, arguments, and options.
Declaration
public Project(string name, ProjectArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| ProjectArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceArn
The ARN of the CodeBuild project.
Declaration
public Output<string> Arn { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Artifacts
Information about the project's build output artifacts. Artifact blocks are documented below.
Declaration
public Output<ProjectArtifacts> Artifacts { get; }
Property Value
| Type | Description |
|---|---|
| Output<ProjectArtifacts> |
BadgeEnabled
Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled.
Declaration
public Output<bool?> BadgeEnabled { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
BadgeUrl
The URL of the build badge when badge_enabled is enabled.
Declaration
public Output<string> BadgeUrl { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
BuildTimeout
How long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed. The default is 60 minutes.
Declaration
public Output<int?> BuildTimeout { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
Cache
Information about the cache storage for the project. Cache blocks are documented below.
Declaration
public Output<ProjectCache> Cache { get; }
Property Value
| Type | Description |
|---|---|
| Output<ProjectCache> |
Description
A short description of the project.
Declaration
public Output<string> Description { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
EncryptionKey
The AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for encrypting the build project's build output artifacts.
Declaration
public Output<string> EncryptionKey { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Environment
Information about the project's build environment. Environment blocks are documented below.
Declaration
public Output<ProjectEnvironment> Environment { get; }
Property Value
| Type | Description |
|---|---|
| Output<ProjectEnvironment> |
LogsConfig
Configuration for the builds to store log data to CloudWatch or S3.
Declaration
public Output<ProjectLogsConfig> LogsConfig { get; }
Property Value
| Type | Description |
|---|---|
| Output<ProjectLogsConfig> |
Name
The projects name.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
QueuedTimeout
How long in minutes, from 5 to 480 (8 hours), a build is allowed to be queued before it times out. The default is 8 hours.
Declaration
public Output<int?> QueuedTimeout { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
SecondaryArtifacts
A set of secondary artifacts to be used inside the build. Secondary artifacts blocks are documented below.
Declaration
public Output<ImmutableArray<ProjectSecondaryArtifact>> SecondaryArtifacts { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ProjectSecondaryArtifact>> |
SecondarySources
A set of secondary sources to be used inside the build. Secondary sources blocks are documented below.
Declaration
public Output<ImmutableArray<ProjectSecondarySource>> SecondarySources { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ProjectSecondarySource>> |
ServiceRole
The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that enables AWS CodeBuild to interact with dependent AWS services on behalf of the AWS account.
Declaration
public Output<string> ServiceRole { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Source
Information about the project's input source code. Source blocks are documented below.
Declaration
public Output<ProjectSource> Source { get; }
Property Value
| Type | Description |
|---|---|
| Output<ProjectSource> |
SourceVersion
A version of the build input to be built for this project. If not specified, the latest version is used.
Declaration
public Output<string> SourceVersion { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Tags
A map of tags to assign to the resource.
Declaration
public Output<ImmutableDictionary<string, object>> Tags { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
VpcConfig
Configuration for the builds to run inside a VPC. VPC config blocks are documented below.
Declaration
public Output<ProjectVpcConfig> VpcConfig { get; }
Property Value
| Type | Description |
|---|---|
| Output<ProjectVpcConfig> |
Methods
View SourceGet(String, Input<String>, ProjectState, CustomResourceOptions)
Get an existing Project resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static Project Get(string name, Input<string> id, ProjectState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| ProjectState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| Project |