community.aws.codebuild_project (5.1.0) — module

Create or delete an AWS CodeBuild project

| "added in version" 1.0.0 of community.aws"

Authors: Stefan Horning (@stefanhorning) <horning@mediapeers.com>

Install collection

Install with ansible-galaxy collection install community.aws:==5.1.0


Add to requirements.yml

  collections:
    - name: community.aws
      version: 5.1.0

Description

Create or delete a CodeBuild projects on AWS, used for building code artifacts from source code.

Prior to release 5.0.0 this module was called C(community.aws.aws_codebuild). The usage did not change.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Note: These examples do not set authentication details, see the AWS Guide for details.

- community.aws.codebuild_project:
    name: my_project
    description: My nice little project
    service_role: "arn:aws:iam::123123:role/service-role/code-build-service-role"
    source:
        # Possible values: BITBUCKET, CODECOMMIT, CODEPIPELINE, GITHUB, S3
        type: CODEPIPELINE
        buildspec: ''
    artifacts:
        namespaceType: NONE
        packaging: NONE
        type: CODEPIPELINE
        name: my_project
    environment:
        computeType: BUILD_GENERAL1_SMALL
        privilegedMode: "true"
        image: "aws/codebuild/docker:17.09.0"
        type: LINUX_CONTAINER
        environmentVariables:
            - { name: 'PROFILE', value: 'staging' }
    encryption_key: "arn:aws:kms:us-east-1:123123:alias/aws/s3"
    region: us-east-1
    state: present

Inputs

    
name:
    description:
    - Name of the CodeBuild project.
    required: true
    type: str

tags:
    description:
    - A set of tags for the build project.
    - Mutually exclusive with the I(resource_tags) parameter.
    - In release 6.0.0 this parameter will accept a simple dictionary instead of the list
      of dictionaries format.  To use the simple dictionary format prior to release 6.0.0
      the I(resource_tags) can be used instead of I(tags).
    elements: dict
    suboptions:
      key:
        description: The name of the Tag.
        type: str
      value:
        description: The value of the Tag.
        type: str
    type: list

cache:
    description:
    - Caching params to speed up following builds.
    suboptions:
      location:
        description:
        - Caching location on S3.
        required: true
      type:
        description:
        - Cache type. Can be C(NO_CACHE) or C(S3).
        required: true
    type: dict

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Create or remove CodeBuild project.
    type: str

region:
    aliases:
    - aws_region
    - ec2_region
    description:
    - The AWS region to use.
    - For global services such as IAM, Route53 and CloudFront, I(region) is ignored.
    - The C(AWS_REGION) or C(EC2_REGION) environment variables may also be used.
    - See the Amazon AWS documentation for more information U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region).
    - The C(ec2_region) alias has been deprecated and will be removed in a release after
      2024-12-01
    - Support for the C(EC2_REGION) environment variable has been deprecated and will
      be removed in a release after 2024-12-01.
    type: str

source:
    description:
    - Configure service and location for the build input source.
    - I(source) is required when creating a new project.
    suboptions:
      buildspec:
        description:
        - The build spec declaration to use for the builds in this build project. Leave
          empty if part of the CodeBuild project.
        type: str
      git_clone_depth:
        description:
        - When using git you can specify the clone depth as an integer here.
        type: int
      insecure_ssl:
        description:
        - Enable this flag to ignore SSL warnings while connecting to the project source
          code.
        type: bool
      location:
        description:
        - Information about the location of the source code to be built. For I(type) C(CODEPIPELINE)
          location should not be specified.
        type: str
      type:
        description:
        - 'The type of the source. Allows one of these: C(CODECOMMIT), C(CODEPIPELINE),
          C(GITHUB), C(S3), C(BITBUCKET), C(GITHUB_ENTERPRISE).'
        required: true
        type: str
    type: dict

profile:
    aliases:
    - aws_profile
    description:
    - A named AWS profile to use for authentication.
    - See the AWS documentation for more information about named profiles U(https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html).
    - The C(AWS_PROFILE) environment variable may also be used.
    - The I(profile) option is mutually exclusive with the I(aws_access_key), I(aws_secret_key)
      and I(security_token) options.
    type: str

artifacts:
    description:
    - Information about the build output artifacts for the build project.
    - I(artifacts) is required when creating a new project.
    suboptions:
      location:
        description:
        - Information about the build output artifact location. When choosing I(type)
          C(S3), set the bucket name here.
      name:
        description:
        - Along with path and namespace_type, the pattern that AWS CodeBuild will use
          to name and store the output artifact.
      namespace_type:
        description:
        - Along with path and name, the pattern that AWS CodeBuild will use to determine
          the name and location to store the output artifacts.
        - Accepts C(BUILD_ID) and C(NONE).
        - 'See docs here: U(http://boto3.readthedocs.io/en/latest/reference/services/codebuild.html#CodeBuild.Client.create_project).'
      packaging:
        description:
        - The type of build output artifact to create on S3, can be NONE for creating
          a folder or ZIP for a ZIP file.
      path:
        description:
        - Along with namespace_type and name, the pattern that AWS CodeBuild will use
          to name and store the output artifacts.
        - Used for path in S3 bucket when type is C(S3).
      type:
        description:
        - 'The type of build output for artifacts. Can be one of the following: C(CODEPIPELINE),
          C(NO_ARTIFACTS), C(S3).'
        required: true
    type: dict

access_key:
    aliases:
    - aws_access_key_id
    - aws_access_key
    - ec2_access_key
    description:
    - AWS access key ID.
    - See the AWS documentation for more information about access tokens U(https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys).
    - The C(AWS_ACCESS_KEY_ID), C(AWS_ACCESS_KEY) or C(EC2_ACCESS_KEY) environment variables
      may also be used in decreasing order of preference.
    - The I(aws_access_key) and I(profile) options are mutually exclusive.
    - The I(aws_access_key_id) alias was added in release 5.1.0 for consistency with the
      AWS botocore SDK.
    - The I(ec2_access_key) alias has been deprecated and will be removed in a release
      after 2024-12-01.
    - Support for the C(EC2_ACCESS_KEY) environment variable has been deprecated and will
      be removed in a release after 2024-12-01.
    type: str

aws_config:
    description:
    - A dictionary to modify the botocore configuration.
    - Parameters can be found in the AWS documentation U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config).
    type: dict

purge_tags:
    default: true
    description:
    - If I(purge_tags=true) and I(tags) is set, existing tags will be purged from the
      resource to match exactly what is defined by I(tags) parameter.
    - If the I(resource_tags) parameter is not set then tags will not be modified, even
      if I(purge_tags=True).
    - Tag keys beginning with C(aws:) are reserved by Amazon and can not be modified.  As
      such they will be ignored for the purposes of the I(purge_tags) parameter.  See
      the Amazon documentation for more information U(https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html#tag-conventions).
    required: false
    type: bool

secret_key:
    aliases:
    - aws_secret_access_key
    - aws_secret_key
    - ec2_secret_key
    description:
    - AWS secret access key.
    - See the AWS documentation for more information about access tokens U(https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys).
    - The C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY), or C(EC2_SECRET_KEY) environment
      variables may also be used in decreasing order of preference.
    - The I(secret_key) and I(profile) options are mutually exclusive.
    - The I(aws_secret_access_key) alias was added in release 5.1.0 for consistency with
      the AWS botocore SDK.
    - The I(ec2_secret_key) alias has been deprecated and will be removed in a release
      after 2024-12-01.
    - Support for the C(EC2_SECRET_KEY) environment variable has been deprecated and will
      be removed in a release after 2024-12-01.
    type: str

vpc_config:
    description:
    - The VPC config enables AWS CodeBuild to access resources in an Amazon VPC.
    type: dict

description:
    description:
    - Descriptive text of the CodeBuild project.
    type: str

environment:
    description:
    - Information about the build environment for the build project.
    suboptions:
      compute_type:
        description:
        - Information about the compute resources the build project will use.
        - 'Available values include: C(BUILD_GENERAL1_SMALL), C(BUILD_GENERAL1_MEDIUM),
          C(BUILD_GENERAL1_LARGE).'
        required: true
      environment_variables:
        description:
        - A set of environment variables to make available to builds for the build project.
          List of dictionaries with name and value fields.
        - 'Example: { name: ''MY_ENV_VARIABLE'', value: ''test'' }'
      image:
        description:
        - The ID of the Docker image to use for this build project.
        required: true
      privileged_mode:
        description:
        - Enables running the Docker daemon inside a Docker container.
        - Set to C(true) only if the build project is be used to build Docker images.
      type:
        description:
        - The type of build environment to use for the project. Usually C(LINUX_CONTAINER).
        required: true
    type: dict

endpoint_url:
    aliases:
    - ec2_url
    - aws_endpoint_url
    - s3_url
    description:
    - URL to connect to instead of the default AWS endpoints.  While this can be used
      to connection to other AWS-compatible services the amazon.aws and community.aws
      collections are only tested against AWS.
    - The  C(AWS_URL) or C(EC2_URL) environment variables may also be used, in decreasing
      order of preference.
    - The I(ec2_url) and I(s3_url) aliases have been deprecated and will be removed in
      a release after 2024-12-01.
    - Support for the C(EC2_URL) environment variable has been deprecated and will be
      removed in a release after 2024-12-01.
    type: str

service_role:
    description:
    - The ARN of the AWS IAM role that enables AWS CodeBuild to interact with dependent
      AWS services on behalf of the AWS account.
    type: str

aws_ca_bundle:
    description:
    - The location of a CA Bundle to use when validating SSL certificates.
    - The C(AWS_CA_BUNDLE) environment variable may also be used.
    type: path

resource_tags:
    description:
    - A dictionary representing the tags to be applied to the build project.
    - If the I(resource_tags) parameter is not set then tags will not be modified.
    - Mutually exclusive with the I(tags) parameter.
    required: false
    type: dict

session_token:
    aliases:
    - aws_session_token
    - security_token
    - aws_security_token
    - access_token
    description:
    - AWS STS session token for use with temporary credentials.
    - See the AWS documentation for more information about access tokens U(https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys).
    - The C(AWS_SESSION_TOKEN), C(AWS_SECURITY_TOKEN) or C(EC2_SECURITY_TOKEN) environment
      variables may also be used in decreasing order of preference.
    - The I(security_token) and I(profile) options are mutually exclusive.
    - Aliases I(aws_session_token) and I(session_token) were added in release 3.2.0, with
      the parameter being renamed from I(security_token) to I(session_token) in release
      6.0.0.
    - The I(security_token), I(aws_security_token), and I(access_token) aliases have been
      deprecated and will be removed in a release after 2024-12-01.
    - Support for the C(EC2_SECRET_KEY) and C(AWS_SECURITY_TOKEN) environment variables
      has been deprecated and will be removed in a release after 2024-12-01.
    type: str

encryption_key:
    description:
    - The AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for
      encrypting the build output artifacts.
    type: str

validate_certs:
    default: true
    description:
    - When set to C(false), SSL certificates will not be validated for communication with
      the AWS APIs.
    - Setting I(validate_certs=false) is strongly discouraged, as an alternative, consider
      setting I(aws_ca_bundle) instead.
    type: bool

timeout_in_minutes:
    default: 60
    description:
    - How long CodeBuild should wait until timing out any build that has not been marked
      as completed.
    type: int

debug_botocore_endpoint_logs:
    default: false
    description:
    - Use a C(botocore.endpoint) logger to parse the unique (rather than total) C("resource:action")
      API calls made during a task, outputing the set to the resource_actions key in the
      task results. Use the C(aws_resource_action) callback to output to total list made
      during a playbook.
    - The C(ANSIBLE_DEBUG_BOTOCORE_LOGS) environment variable may also be used.
    type: bool

Outputs

project:
  contains:
    arn:
      description: ARN of the CodeBuild project.
      returned: always
      sample: arn:aws:codebuild:us-east-1:123123123:project/vod-api-app-builder
      type: str
    artifacts:
      contains:
        location:
          description: Output location for build artifacts.
          returned: when configured
          type: str
        type:
          description: The type of build artifact.
          returned: always
          sample: CODEPIPELINE
          type: str
      description: Information about the output of build artifacts
      returned: always
      type: complex
    cache:
      description: Cache settings for the build project.
      returned: when configured
      type: dict
    created:
      description: Timestamp of the create time of the project.
      returned: always
      sample: '2018-04-17T16:56:03.245000+02:00'
      type: str
    description:
      description: A description of the CodeBuild project.
      returned: always
      sample: My nice little project
      type: str
    environment:
      description: Environment settings for the build.
      returned: always
      type: dict
    name:
      description: Name of the CodeBuild project.
      returned: always
      sample: my_project
      type: str
    reource_tags:
      description:
      - A simple dictionary representing the tags added to the project.
      - I(tags) and I(reource_tags) represent the same information in different formats.
      returned: when configured
      type: dict
      version_added: 4.0.0
      version_added_collection: community.aws
    service_role:
      description: IAM role to be used during build to access other AWS services.
      returned: always
      sample: arn:aws:iam::123123123:role/codebuild-service-role
      type: str
    source:
      contains:
        auth:
          description: Information about the authorization settings for AWS CodeBuild
            to access the source code to be built.
          returned: when configured
          type: complex
        build_spec:
          description: The build spec declaration to use for the builds in this build
            project.
          returned: always
          type: str
        git_clone_depth:
          description: The git clone depth.
          returned: when configured
          type: int
        insecure_ssl:
          description: True if set to ignore SSL warnings.
          returned: when configured
          type: bool
        location:
          description: Location identifier, depending on the source type.
          returned: when configured
          type: str
        type:
          description: The type of the repository.
          returned: always
          sample: CODEPIPELINE
          type: str
      description: Information about the build input source code.
      returned: always
      type: complex
    tags:
      description:
      - Tags added to the project in the boto3 list of dictionaries format.
      - I(tags) and I(reource_tags) represent the same information in different formats.
      returned: when configured
      type: list
    timeout_in_minutes:
      description: The timeout of a build in minutes.
      returned: always
      sample: 60
      type: int
  description: Returns the dictionary describing the code project configuration.
  returned: success
  type: complex