Class Project


  • public class Project
    extends com.pulumi.resources.CustomResource
    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 <!--Start PulumiCodeChooser --> ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.s3.BucketV2; import com.pulumi.aws.s3.BucketV2Args; import com.pulumi.aws.s3.BucketAclV2; import com.pulumi.aws.s3.BucketAclV2Args; import com.pulumi.aws.iam.IamFunctions; import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs; import com.pulumi.aws.iam.Role; import com.pulumi.aws.iam.RoleArgs; import com.pulumi.aws.iam.RolePolicy; import com.pulumi.aws.iam.RolePolicyArgs; import com.pulumi.aws.codebuild.Project; import com.pulumi.aws.codebuild.ProjectArgs; import com.pulumi.aws.codebuild.inputs.ProjectArtifactsArgs; import com.pulumi.aws.codebuild.inputs.ProjectCacheArgs; import com.pulumi.aws.codebuild.inputs.ProjectEnvironmentArgs; import com.pulumi.aws.codebuild.inputs.ProjectLogsConfigArgs; import com.pulumi.aws.codebuild.inputs.ProjectLogsConfigCloudwatchLogsArgs; import com.pulumi.aws.codebuild.inputs.ProjectLogsConfigS3LogsArgs; import com.pulumi.aws.codebuild.inputs.ProjectSourceArgs; import com.pulumi.aws.codebuild.inputs.ProjectSourceGitSubmodulesConfigArgs; import com.pulumi.aws.codebuild.inputs.ProjectVpcConfigArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var exampleBucketV2 = new BucketV2("exampleBucketV2", BucketV2Args.builder() .bucket("example") .build()); var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder() .bucket(exampleBucketV2.id()) .acl("private") .build()); final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder() .statements(GetPolicyDocumentStatementArgs.builder() .effect("Allow") .principals(GetPolicyDocumentStatementPrincipalArgs.builder() .type("Service") .identifiers("codebuild.amazonaws.com") .build()) .actions("sts:AssumeRole") .build()) .build()); var exampleRole = new Role("exampleRole", RoleArgs.builder() .name("example") .assumeRolePolicy(assumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())) .build()); final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder() .statements( GetPolicyDocumentStatementArgs.builder() .effect("Allow") .actions( "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents") .resources("*") .build(), GetPolicyDocumentStatementArgs.builder() .effect("Allow") .actions( "ec2:CreateNetworkInterface", "ec2:DescribeDhcpOptions", "ec2:DescribeNetworkInterfaces", "ec2:DeleteNetworkInterface", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeVpcs") .resources("*") .build(), GetPolicyDocumentStatementArgs.builder() .effect("Allow") .actions("ec2:CreateNetworkInterfacePermission") .resources("arn:aws:ec2:us-east-1:123456789012:network-interface/*") .conditions( GetPolicyDocumentStatementConditionArgs.builder() .test("StringEquals") .variable("ec2:Subnet") .values( example1.arn(), example2.arn()) .build(), GetPolicyDocumentStatementConditionArgs.builder() .test("StringEquals") .variable("ec2:AuthorizedService") .values("codebuild.amazonaws.com") .build()) .build(), GetPolicyDocumentStatementArgs.builder() .effect("Allow") .actions("s3:*") .resources( exampleBucketV2.arn(), exampleBucketV2.arn().applyValue(arn -> String.format("%s/*", arn))) .build()) .build()); var exampleRolePolicy = new RolePolicy("exampleRolePolicy", RolePolicyArgs.builder() .role(exampleRole.name()) .policy(example.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(example -> example.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))) .build()); var exampleProject = new Project("exampleProject", ProjectArgs.builder() .name("test-project") .description("test_codebuild_project") .buildTimeout(5) .serviceRole(exampleRole.arn()) .artifacts(ProjectArtifactsArgs.builder() .type("NO_ARTIFACTS") .build()) .cache(ProjectCacheArgs.builder() .type("S3") .location(exampleBucketV2.bucket()) .build()) .environment(ProjectEnvironmentArgs.builder() .computeType("BUILD_GENERAL1_SMALL") .image("aws/codebuild/amazonlinux2-x86_64-standard:4.0") .type("LINUX_CONTAINER") .imagePullCredentialsType("CODEBUILD") .environmentVariables( ProjectEnvironmentEnvironmentVariableArgs.builder() .name("SOME_KEY1") .value("SOME_VALUE1") .build(), ProjectEnvironmentEnvironmentVariableArgs.builder() .name("SOME_KEY2") .value("SOME_VALUE2") .type("PARAMETER_STORE") .build()) .build()) .logsConfig(ProjectLogsConfigArgs.builder() .cloudwatchLogs(ProjectLogsConfigCloudwatchLogsArgs.builder() .groupName("log-group") .streamName("log-stream") .build()) .s3Logs(ProjectLogsConfigS3LogsArgs.builder() .status("ENABLED") .location(exampleBucketV2.id().applyValue(id -> String.format("%s/build-log", id))) .build()) .build()) .source(ProjectSourceArgs.builder() .type("GITHUB") .location("https://github.com/mitchellh/packer.git") .gitCloneDepth(1) .gitSubmodulesConfig(ProjectSourceGitSubmodulesConfigArgs.builder() .fetchSubmodules(true) .build()) .build()) .sourceVersion("master") .vpcConfig(ProjectVpcConfigArgs.builder() .vpcId(exampleAwsVpc.id()) .subnets( example1.id(), example2.id()) .securityGroupIds( example1AwsSecurityGroup.id(), example2AwsSecurityGroup.id()) .build()) .tags(Map.of("Environment", "Test")) .build()); var project_with_cache = new Project("project-with-cache", ProjectArgs.builder() .name("test-project-cache") .description("test_codebuild_project_cache") .buildTimeout(5) .queuedTimeout(5) .serviceRole(exampleRole.arn()) .artifacts(ProjectArtifactsArgs.builder() .type("NO_ARTIFACTS") .build()) .cache(ProjectCacheArgs.builder() .type("LOCAL") .modes( "LOCAL_DOCKER_LAYER_CACHE", "LOCAL_SOURCE_CACHE") .build()) .environment(ProjectEnvironmentArgs.builder() .computeType("BUILD_GENERAL1_SMALL") .image("aws/codebuild/amazonlinux2-x86_64-standard:4.0") .type("LINUX_CONTAINER") .imagePullCredentialsType("CODEBUILD") .environmentVariables(ProjectEnvironmentEnvironmentVariableArgs.builder() .name("SOME_KEY1") .value("SOME_VALUE1") .build()) .build()) .source(ProjectSourceArgs.builder() .type("GITHUB") .location("https://github.com/mitchellh/packer.git") .gitCloneDepth(1) .build()) .tags(Map.of("Environment", "Test")) .build()); } } ``` <!--End PulumiCodeChooser --> ## Import Using `pulumi import`, import CodeBuild Project using the `name`. For example: ```sh $ pulumi import aws:codebuild/project:Project name project-name ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Project​(java.lang.String name)  
      Project​(java.lang.String name, ProjectArgs args)  
      Project​(java.lang.String name, ProjectArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Constructor Detail

      • Project

        public Project​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Project

        public Project​(java.lang.String name,
                       ProjectArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Project

        public Project​(java.lang.String name,
                       ProjectArgs args,
                       @Nullable
                       com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of the CodeBuild project.
      • artifacts

        public com.pulumi.core.Output<ProjectArtifacts> artifacts()
        Returns:
        Configuration block. Detailed below.
      • badgeEnabled

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> badgeEnabled()
        Returns:
        Generates a publicly-accessible URL for the projects build badge. Available as `badge_url` attribute when enabled.
      • badgeUrl

        public com.pulumi.core.Output<java.lang.String> badgeUrl()
        Returns:
        URL of the build badge when `badge_enabled` is enabled.
      • buildBatchConfig

        public com.pulumi.core.Output<java.util.Optional<ProjectBuildBatchConfig>> buildBatchConfig()
        Returns:
        Defines the batch build options for the project.
      • buildTimeout

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> buildTimeout()
        Returns:
        Number of 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. The `build_timeout` property is not available on the `Lambda` compute type.
      • cache

        public com.pulumi.core.Output<java.util.Optional<ProjectCache>> cache()
        Returns:
        Configuration block. Detailed below.
      • concurrentBuildLimit

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> concurrentBuildLimit()
        Returns:
        Specify a maximum number of concurrent builds for the project. The value specified must be greater than 0 and less than the account concurrent running builds limit.
      • description

        public com.pulumi.core.Output<java.lang.String> description()
        Returns:
        Short description of the project.
      • encryptionKey

        public com.pulumi.core.Output<java.lang.String> encryptionKey()
        Returns:
        AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for encrypting the build project's build output artifacts.
      • environment

        public com.pulumi.core.Output<ProjectEnvironment> environment()
        Returns:
        Configuration block. Detailed below.
      • fileSystemLocations

        public com.pulumi.core.Output<java.util.Optional<java.util.List<ProjectFileSystemLocation>>> fileSystemLocations()
        Returns:
        A set of file system locations to mount inside the build. File system locations are documented below.
      • logsConfig

        public com.pulumi.core.Output<java.util.Optional<ProjectLogsConfig>> logsConfig()
        Returns:
        Configuration block. Detailed below.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Project's name.
      • projectVisibility

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> projectVisibility()
        Returns:
        Specifies the visibility of the project's builds. Possible values are: `PUBLIC_READ` and `PRIVATE`. Default value is `PRIVATE`.
      • publicProjectAlias

        public com.pulumi.core.Output<java.lang.String> publicProjectAlias()
        Returns:
        The project identifier used with the public build APIs.
      • queuedTimeout

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> queuedTimeout()
        Returns:
        Number of minutes, from 5 to 480 (8 hours), a build is allowed to be queued before it times out. The default is 8 hours. The `queued_timeout` property is not available on the `Lambda` compute type.
      • resourceAccessRole

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> resourceAccessRole()
        Returns:
        The ARN of the IAM role that enables CodeBuild to access the CloudWatch Logs and Amazon S3 artifacts for the project's builds in order to display them publicly. Only applicable if `project_visibility` is `PUBLIC_READ`.
      • secondaryArtifacts

        public com.pulumi.core.Output<java.util.Optional<java.util.List<ProjectSecondaryArtifact>>> secondaryArtifacts()
        Returns:
        Configuration block. Detailed below.
      • secondarySourceVersions

        public com.pulumi.core.Output<java.util.Optional<java.util.List<ProjectSecondarySourceVersion>>> secondarySourceVersions()
        Returns:
        Configuration block. Detailed below.
      • secondarySources

        public com.pulumi.core.Output<java.util.Optional<java.util.List<ProjectSecondarySource>>> secondarySources()
        Returns:
        Configuration block. Detailed below.
      • serviceRole

        public com.pulumi.core.Output<java.lang.String> serviceRole()
        Returns:
        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.
      • source

        public com.pulumi.core.Output<ProjectSource> source()
        Returns:
        Configuration block. Detailed below. The following arguments are optional:
      • sourceVersion

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> sourceVersion()
        Returns:
        Version of the build input to be built for this project. If not specified, the latest version is used.
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()
        Returns:
        Map of tags to assign to the resource. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
      • tagsAll

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()
        Returns:
        A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block.
      • vpcConfig

        public com.pulumi.core.Output<java.util.Optional<ProjectVpcConfig>> vpcConfig()
        Returns:
        Configuration block. Detailed below.
      • get

        public static Project get​(java.lang.String name,
                                  com.pulumi.core.Output<java.lang.String> id,
                                  @Nullable
                                  ProjectState state,
                                  @Nullable
                                  com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.