community.aws.aws_codebuild (4.3.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:==4.3.0


Add to requirements.yml

  collections:
    - name: community.aws
      version: 4.3.0

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.

- community.aws.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
    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 code build project.
    type: str

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.
    - 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 code 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 type 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

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:
    - Uses a boto profile. Only works with boto >= 2.24.0.
    - 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.
    - I(artifacts) is required when creating a new project.
    suboptions:
      location:
        description:
        - Information about the build output artifact location. When choosing type 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

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

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

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

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.
    - Only used for boto3 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

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

aws_access_key:
    aliases:
    - ec2_access_key
    - access_key
    description:
    - AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY
      or 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:
    - AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY,
      or 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.
    type: str

security_token:
    aliases:
    - aws_security_token
    - access_token
    description:
    - AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or 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 boto versions >= 2.6.0.
    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: '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
    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