ansible.builtin.aws_codebuild (v2.9.17) — module

Create or delete an AWS CodeBuild project

| "added in version" 2.9 of ansible.builtin"

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

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.17

Description

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


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.

- aws_codebuild:
    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

tags:
    description:
    - A set of tags for the build project.
    required: false

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

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Create or remove code build project.

region:
    aliases:
    - aws_region
    - ec2_region
    description:
    - The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION
      environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region)
    type: str

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

ec2_url:
    aliases:
    - aws_endpoint_url
    - endpoint_url
    description:
    - URL to use to connect to EC2 or your Eucalyptus cloud (by default the module will
      use EC2 endpoints). Ignored for modules where region is required. Must be specified
      for all other modules if region is not used. If not set then the value of the EC2_URL
      environment variable, if any, is used.
    type: str

profile:
    aliases:
    - aws_profile
    description:
    - Using I(profile) will override I(aws_access_key), I(aws_secret_key) and I(security_token)
      and support for passing them at the same time as I(profile) has been deprecated.
    - I(aws_access_key), I(aws_secret_key) and I(security_token) will be made mutually
      exclusive with I(profile) after 2022-06-01.
    type: str

artifacts:
    description:
    - Information about the build output artifacts for the build project.
    required: true
    suboptions:
      location:
        description:
        - Information about the build output artifact location. When choosing type S3,
          set the bucket name here.
        required: false
      name:
        description:
        - Along with path and namespace_type, the pattern that AWS CodeBuild will use
          to name and store the output artifact
        required: false
      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 BUILD_ID and NONE
        - 'See docs here: http://boto3.readthedocs.io/en/latest/reference/services/codebuild.html#CodeBuild.Client.create_project'
        required: false
      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
        required: false
      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 S3
        required: false
      type:
        description:
        - 'The type of build output for artifacts. Can be one of the following: CODEPIPELINE,
          NO_ARTIFACTS, S3'
        required: true

aws_config:
    description:
    - A dictionary to modify the botocore configuration.
    - Parameters can be found at U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config).
    - Only the 'user_agent' key is used for boto modules. See U(http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto)
      for more boto configuration.
    type: dict

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

description:
    description:
    - Descriptive text of the CodeBuild project
    required: false

environment:
    description:
    - Information about the build environment for the build project.
    required: true
    suboptions:
      compute_type:
        description:
        - Information about the compute resources the build project will use.
        - 'Available values include: BUILD_GENERAL1_SMALL, BUILD_GENERAL1_MEDIUM, 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'' }'
        required: false
      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 true only
          if the build project is be used to build Docker images.
        required: false
      type:
        description:
        - The type of build environment to use for the project. Usually LINUX_CONTAINER
        required: true

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.
    required: false

aws_ca_bundle:
    description:
    - The location of a CA Bundle to use when validating SSL certificates.
    - Not used by boto 2 based modules.
    - 'Note: The CA Bundle is read ''module'' side and may need to be explicitly copied
      from the controller if not run locally.'
    type: path

aws_access_key:
    aliases:
    - ec2_access_key
    - access_key
    description:
    - C(AWS access key). If not set then the value of the C(AWS_ACCESS_KEY_ID), C(AWS_ACCESS_KEY)
      or C(EC2_ACCESS_KEY) environment variable is used.
    - If I(profile) is set this parameter is ignored.
    - Passing the I(aws_access_key) and I(profile) options at the same time has been deprecated
      and the options will be made mutually exclusive after 2022-06-01.
    type: str

aws_secret_key:
    aliases:
    - ec2_secret_key
    - secret_key
    description:
    - C(AWS secret key). If not set then the value of the C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY),
      or C(EC2_SECRET_KEY) environment variable is used.
    - If I(profile) is set this parameter is ignored.
    - Passing the I(aws_secret_key) and I(profile) options at the same time has been deprecated
      and the options will be made mutually exclusive after 2022-06-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.
    required: false

security_token:
    aliases:
    - aws_security_token
    - access_token
    description:
    - C(AWS STS security token). If not set then the value of the C(AWS_SECURITY_TOKEN)
      or C(EC2_SECURITY_TOKEN) environment variable is used.
    - If I(profile) is set this parameter is ignored.
    - Passing the I(security_token) and I(profile) options at the same time has been deprecated
      and the options will be made mutually exclusive after 2022-06-01.
    type: str

validate_certs:
    default: true
    description:
    - When set to "no", SSL certificates will not be validated for communication with
      the AWS APIs.
    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.
    required: false

debug_botocore_endpoint_logs:
    default: 'no'
    description:
    - Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action"
      API calls made during a task, outputing the set to the resource_actions key in the
      task results. Use the aws_resource_action callback to output to total list made
      during a playbook. The 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 build 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
    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
      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