# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from .. import _utilities, _tables
from . import outputs
from ._inputs import *

__all__ = ['Project']


class Project(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 artifacts: Optional[pulumi.Input[pulumi.InputType['ProjectArtifactsArgs']]] = None,
                 badge_enabled: Optional[pulumi.Input[bool]] = None,
                 build_timeout: Optional[pulumi.Input[int]] = None,
                 cache: Optional[pulumi.Input[pulumi.InputType['ProjectCacheArgs']]] = None,
                 description: Optional[pulumi.Input[str]] = None,
                 encryption_key: Optional[pulumi.Input[str]] = None,
                 environment: Optional[pulumi.Input[pulumi.InputType['ProjectEnvironmentArgs']]] = None,
                 logs_config: Optional[pulumi.Input[pulumi.InputType['ProjectLogsConfigArgs']]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 queued_timeout: Optional[pulumi.Input[int]] = None,
                 secondary_artifacts: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondaryArtifactArgs']]]]] = None,
                 secondary_sources: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondarySourceArgs']]]]] = None,
                 service_role: Optional[pulumi.Input[str]] = None,
                 source: Optional[pulumi.Input[pulumi.InputType['ProjectSourceArgs']]] = None,
                 source_version: Optional[pulumi.Input[str]] = None,
                 tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                 vpc_config: Optional[pulumi.Input[pulumi.InputType['ProjectVpcConfigArgs']]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides a CodeBuild Project resource. See also the `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

        ```python
        import pulumi
        import pulumi_aws as aws

        example_bucket = aws.s3.Bucket("exampleBucket", acl="private")
        example_role = aws.iam.Role("exampleRole", assume_role_policy=\"\"\"{
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": "codebuild.amazonaws.com"
              },
              "Action": "sts:AssumeRole"
            }
          ]
        }
        \"\"\")
        example_role_policy = aws.iam.RolePolicy("exampleRolePolicy",
            role=example_role.name,
            policy=pulumi.Output.all(example_bucket.arn, example_bucket.arn).apply(lambda exampleBucketArn, exampleBucketArn1: f\"\"\"{{
          "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": [
                "{example_bucket_arn}",
                "{example_bucket_arn1}/*"
              ]
            }}
          ]
        }}
        \"\"\"))
        example_project = aws.codebuild.Project("exampleProject",
            description="test_codebuild_project",
            build_timeout=5,
            service_role=example_role.arn,
            artifacts=aws.codebuild.ProjectArtifactsArgs(
                type="NO_ARTIFACTS",
            ),
            cache=aws.codebuild.ProjectCacheArgs(
                type="S3",
                location=example_bucket.bucket,
            ),
            environment=aws.codebuild.ProjectEnvironmentArgs(
                compute_type="BUILD_GENERAL1_SMALL",
                image="aws/codebuild/standard:1.0",
                type="LINUX_CONTAINER",
                image_pull_credentials_type="CODEBUILD",
                environment_variables=[
                    aws.codebuild.ProjectEnvironmentEnvironmentVariableArgs(
                        name="SOME_KEY1",
                        value="SOME_VALUE1",
                    ),
                    aws.codebuild.ProjectEnvironmentEnvironmentVariableArgs(
                        name="SOME_KEY2",
                        value="SOME_VALUE2",
                        type="PARAMETER_STORE",
                    ),
                ],
            ),
            logs_config=aws.codebuild.ProjectLogsConfigArgs(
                cloudwatch_logs=aws.codebuild.ProjectLogsConfigCloudwatchLogsArgs(
                    group_name="log-group",
                    stream_name="log-stream",
                ),
                s3_logs=aws.codebuild.ProjectLogsConfigS3LogsArgs(
                    status="ENABLED",
                    location=example_bucket.id.apply(lambda id: f"{id}/build-log"),
                ),
            ),
            source=aws.codebuild.ProjectSourceArgs(
                type="GITHUB",
                location="https://github.com/mitchellh/packer.git",
                git_clone_depth=1,
                git_submodules_config=aws.codebuild.ProjectSourceGitSubmodulesConfigArgs(
                    fetch_submodules=True,
                ),
            ),
            source_version="master",
            vpc_config=aws.codebuild.ProjectVpcConfigArgs(
                vpc_id=aws_vpc["example"]["id"],
                subnets=[
                    aws_subnet["example1"]["id"],
                    aws_subnet["example2"]["id"],
                ],
                security_group_ids=[
                    aws_security_group["example1"]["id"],
                    aws_security_group["example2"]["id"],
                ],
            ),
            tags={
                "Environment": "Test",
            })
        project_with_cache = aws.codebuild.Project("project-with-cache",
            description="test_codebuild_project_cache",
            build_timeout=5,
            queued_timeout=5,
            service_role=example_role.arn,
            artifacts=aws.codebuild.ProjectArtifactsArgs(
                type="NO_ARTIFACTS",
            ),
            cache=aws.codebuild.ProjectCacheArgs(
                type="LOCAL",
                modes=[
                    "LOCAL_DOCKER_LAYER_CACHE",
                    "LOCAL_SOURCE_CACHE",
                ],
            ),
            environment=aws.codebuild.ProjectEnvironmentArgs(
                compute_type="BUILD_GENERAL1_SMALL",
                image="aws/codebuild/standard:1.0",
                type="LINUX_CONTAINER",
                image_pull_credentials_type="CODEBUILD",
                environment_variables=[aws.codebuild.ProjectEnvironmentEnvironmentVariableArgs(
                    name="SOME_KEY1",
                    value="SOME_VALUE1",
                )],
            ),
            source=aws.codebuild.ProjectSourceArgs(
                type="GITHUB",
                location="https://github.com/mitchellh/packer.git",
                git_clone_depth=1,
            ),
            tags={
                "Environment": "Test",
            })
        ```

        ## Import

        CodeBuild Project can be imported using the `name`, e.g.

        ```sh
         $ pulumi import aws:codebuild/project:Project name project-name
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[pulumi.InputType['ProjectArtifactsArgs']] artifacts: Configuration block. Detailed below.
        :param pulumi.Input[bool] badge_enabled: Generates a publicly-accessible URL for the projects build badge. Available as `badge_url` attribute when enabled.
        :param pulumi.Input[int] build_timeout: 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.
        :param pulumi.Input[pulumi.InputType['ProjectCacheArgs']] cache: Configuration block. Detailed below.
        :param pulumi.Input[str] description: Short description of the project.
        :param pulumi.Input[str] encryption_key: AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for encrypting the build project's build output artifacts.
        :param pulumi.Input[pulumi.InputType['ProjectEnvironmentArgs']] environment: Configuration block. Detailed below.
        :param pulumi.Input[pulumi.InputType['ProjectLogsConfigArgs']] logs_config: Configuration block. Detailed below.
        :param pulumi.Input[str] name: Name of the project. If `type` is set to `S3`, this is the name of the output artifact object
        :param pulumi.Input[int] queued_timeout: 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.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondaryArtifactArgs']]]] secondary_artifacts: Configuration block. Detailed below.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondarySourceArgs']]]] secondary_sources: Configuration block. Detailed below.
        :param pulumi.Input[str] service_role: 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.
        :param pulumi.Input[pulumi.InputType['ProjectSourceArgs']] source: Configuration block. Detailed below.
        :param pulumi.Input[str] source_version: Version of the build input to be built for this project. If not specified, the latest version is used.
        :param pulumi.Input[Mapping[str, pulumi.Input[str]]] tags: Map of tags to assign to the resource.
        :param pulumi.Input[pulumi.InputType['ProjectVpcConfigArgs']] vpc_config: Configuration block. Detailed below.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            if artifacts is None and not opts.urn:
                raise TypeError("Missing required property 'artifacts'")
            __props__['artifacts'] = artifacts
            __props__['badge_enabled'] = badge_enabled
            __props__['build_timeout'] = build_timeout
            __props__['cache'] = cache
            __props__['description'] = description
            __props__['encryption_key'] = encryption_key
            if environment is None and not opts.urn:
                raise TypeError("Missing required property 'environment'")
            __props__['environment'] = environment
            __props__['logs_config'] = logs_config
            __props__['name'] = name
            __props__['queued_timeout'] = queued_timeout
            __props__['secondary_artifacts'] = secondary_artifacts
            __props__['secondary_sources'] = secondary_sources
            if service_role is None and not opts.urn:
                raise TypeError("Missing required property 'service_role'")
            __props__['service_role'] = service_role
            if source is None and not opts.urn:
                raise TypeError("Missing required property 'source'")
            __props__['source'] = source
            __props__['source_version'] = source_version
            __props__['tags'] = tags
            __props__['vpc_config'] = vpc_config
            __props__['arn'] = None
            __props__['badge_url'] = None
        super(Project, __self__).__init__(
            'aws:codebuild/project:Project',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            arn: Optional[pulumi.Input[str]] = None,
            artifacts: Optional[pulumi.Input[pulumi.InputType['ProjectArtifactsArgs']]] = None,
            badge_enabled: Optional[pulumi.Input[bool]] = None,
            badge_url: Optional[pulumi.Input[str]] = None,
            build_timeout: Optional[pulumi.Input[int]] = None,
            cache: Optional[pulumi.Input[pulumi.InputType['ProjectCacheArgs']]] = None,
            description: Optional[pulumi.Input[str]] = None,
            encryption_key: Optional[pulumi.Input[str]] = None,
            environment: Optional[pulumi.Input[pulumi.InputType['ProjectEnvironmentArgs']]] = None,
            logs_config: Optional[pulumi.Input[pulumi.InputType['ProjectLogsConfigArgs']]] = None,
            name: Optional[pulumi.Input[str]] = None,
            queued_timeout: Optional[pulumi.Input[int]] = None,
            secondary_artifacts: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondaryArtifactArgs']]]]] = None,
            secondary_sources: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondarySourceArgs']]]]] = None,
            service_role: Optional[pulumi.Input[str]] = None,
            source: Optional[pulumi.Input[pulumi.InputType['ProjectSourceArgs']]] = None,
            source_version: Optional[pulumi.Input[str]] = None,
            tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
            vpc_config: Optional[pulumi.Input[pulumi.InputType['ProjectVpcConfigArgs']]] = None) -> 'Project':
        """
        Get an existing Project resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] arn: ARN of the CodeBuild project.
        :param pulumi.Input[pulumi.InputType['ProjectArtifactsArgs']] artifacts: Configuration block. Detailed below.
        :param pulumi.Input[bool] badge_enabled: Generates a publicly-accessible URL for the projects build badge. Available as `badge_url` attribute when enabled.
        :param pulumi.Input[str] badge_url: URL of the build badge when `badge_enabled` is enabled.
        :param pulumi.Input[int] build_timeout: 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.
        :param pulumi.Input[pulumi.InputType['ProjectCacheArgs']] cache: Configuration block. Detailed below.
        :param pulumi.Input[str] description: Short description of the project.
        :param pulumi.Input[str] encryption_key: AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for encrypting the build project's build output artifacts.
        :param pulumi.Input[pulumi.InputType['ProjectEnvironmentArgs']] environment: Configuration block. Detailed below.
        :param pulumi.Input[pulumi.InputType['ProjectLogsConfigArgs']] logs_config: Configuration block. Detailed below.
        :param pulumi.Input[str] name: Name of the project. If `type` is set to `S3`, this is the name of the output artifact object
        :param pulumi.Input[int] queued_timeout: 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.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondaryArtifactArgs']]]] secondary_artifacts: Configuration block. Detailed below.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ProjectSecondarySourceArgs']]]] secondary_sources: Configuration block. Detailed below.
        :param pulumi.Input[str] service_role: 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.
        :param pulumi.Input[pulumi.InputType['ProjectSourceArgs']] source: Configuration block. Detailed below.
        :param pulumi.Input[str] source_version: Version of the build input to be built for this project. If not specified, the latest version is used.
        :param pulumi.Input[Mapping[str, pulumi.Input[str]]] tags: Map of tags to assign to the resource.
        :param pulumi.Input[pulumi.InputType['ProjectVpcConfigArgs']] vpc_config: Configuration block. Detailed below.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["arn"] = arn
        __props__["artifacts"] = artifacts
        __props__["badge_enabled"] = badge_enabled
        __props__["badge_url"] = badge_url
        __props__["build_timeout"] = build_timeout
        __props__["cache"] = cache
        __props__["description"] = description
        __props__["encryption_key"] = encryption_key
        __props__["environment"] = environment
        __props__["logs_config"] = logs_config
        __props__["name"] = name
        __props__["queued_timeout"] = queued_timeout
        __props__["secondary_artifacts"] = secondary_artifacts
        __props__["secondary_sources"] = secondary_sources
        __props__["service_role"] = service_role
        __props__["source"] = source
        __props__["source_version"] = source_version
        __props__["tags"] = tags
        __props__["vpc_config"] = vpc_config
        return Project(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def arn(self) -> pulumi.Output[str]:
        """
        ARN of the CodeBuild project.
        """
        return pulumi.get(self, "arn")

    @property
    @pulumi.getter
    def artifacts(self) -> pulumi.Output['outputs.ProjectArtifacts']:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "artifacts")

    @property
    @pulumi.getter(name="badgeEnabled")
    def badge_enabled(self) -> pulumi.Output[Optional[bool]]:
        """
        Generates a publicly-accessible URL for the projects build badge. Available as `badge_url` attribute when enabled.
        """
        return pulumi.get(self, "badge_enabled")

    @property
    @pulumi.getter(name="badgeUrl")
    def badge_url(self) -> pulumi.Output[str]:
        """
        URL of the build badge when `badge_enabled` is enabled.
        """
        return pulumi.get(self, "badge_url")

    @property
    @pulumi.getter(name="buildTimeout")
    def build_timeout(self) -> pulumi.Output[Optional[int]]:
        """
        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.
        """
        return pulumi.get(self, "build_timeout")

    @property
    @pulumi.getter
    def cache(self) -> pulumi.Output[Optional['outputs.ProjectCache']]:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "cache")

    @property
    @pulumi.getter
    def description(self) -> pulumi.Output[str]:
        """
        Short description of the project.
        """
        return pulumi.get(self, "description")

    @property
    @pulumi.getter(name="encryptionKey")
    def encryption_key(self) -> pulumi.Output[str]:
        """
        AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for encrypting the build project's build output artifacts.
        """
        return pulumi.get(self, "encryption_key")

    @property
    @pulumi.getter
    def environment(self) -> pulumi.Output['outputs.ProjectEnvironment']:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "environment")

    @property
    @pulumi.getter(name="logsConfig")
    def logs_config(self) -> pulumi.Output[Optional['outputs.ProjectLogsConfig']]:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "logs_config")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        Name of the project. If `type` is set to `S3`, this is the name of the output artifact object
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="queuedTimeout")
    def queued_timeout(self) -> pulumi.Output[Optional[int]]:
        """
        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.
        """
        return pulumi.get(self, "queued_timeout")

    @property
    @pulumi.getter(name="secondaryArtifacts")
    def secondary_artifacts(self) -> pulumi.Output[Optional[Sequence['outputs.ProjectSecondaryArtifact']]]:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "secondary_artifacts")

    @property
    @pulumi.getter(name="secondarySources")
    def secondary_sources(self) -> pulumi.Output[Optional[Sequence['outputs.ProjectSecondarySource']]]:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "secondary_sources")

    @property
    @pulumi.getter(name="serviceRole")
    def service_role(self) -> pulumi.Output[str]:
        """
        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.
        """
        return pulumi.get(self, "service_role")

    @property
    @pulumi.getter
    def source(self) -> pulumi.Output['outputs.ProjectSource']:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "source")

    @property
    @pulumi.getter(name="sourceVersion")
    def source_version(self) -> pulumi.Output[Optional[str]]:
        """
        Version of the build input to be built for this project. If not specified, the latest version is used.
        """
        return pulumi.get(self, "source_version")

    @property
    @pulumi.getter
    def tags(self) -> pulumi.Output[Optional[Mapping[str, str]]]:
        """
        Map of tags to assign to the resource.
        """
        return pulumi.get(self, "tags")

    @property
    @pulumi.getter(name="vpcConfig")
    def vpc_config(self) -> pulumi.Output[Optional['outputs.ProjectVpcConfig']]:
        """
        Configuration block. Detailed below.
        """
        return pulumi.get(self, "vpc_config")

    def translate_output_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

