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

Manage secrets stored in AWS Secrets Manager.

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

Authors: REY Remi (@rrey)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.17

Description

Create, update, and delete secrets stored in AWS Secrets Manager.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add string to AWS Secrets Manager
  aws_secret:
    name: 'test_secret_string'
    state: present
    secret_type: 'string'
    secret: "{{ super_secret_string }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: remove string from AWS Secrets Manager
  aws_secret:
    name: 'test_secret_string'
    state: absent
    secret_type: 'string'
    secret: "{{ super_secret_string }}"

Inputs

    
name:
    description:
    - Friendly name for the secret you are creating.
    required: true

tags:
    description:
    - Specifies a list of user-defined tags that are attached to the secret.

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Whether the secret should be exist or not.

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

secret:
    default: ''
    description:
    - Specifies string or binary data that you want to encrypt and store in the new version
      of the secret.

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

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

kms_key_id:
    description:
    - Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to
      encrypt the `secret_string` or `secret_binary` values in the versions stored in
      this secret.

description:
    description:
    - Specifies a user-provided description of the secret.

secret_type:
    choices:
    - binary
    - string
    default: string
    description:
    - Specifies the type of data that you want to encrypt.

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

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

recovery_window:
    default: 30
    description:
    - Only used if state is absent.
    - Specifies the number of days that Secrets Manager waits before it can delete the
      secret.
    - If set to 0, the deletion is forced without recovery.

rotation_lambda:
    description:
    - Specifies the ARN of the Lambda function that can rotate the secret.

rotation_interval:
    default: 30
    description:
    - Specifies the number of days between automatic scheduled rotations of the secret.

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

secret:
  contains:
    arn:
      description: The ARN of the secret
      returned: always
      sample: arn:aws:secretsmanager:eu-west-1:xxxxxxxxxx:secret:xxxxxxxxxxx
      type: str
    last_accessed_date:
      description: The date the secret was last accessed
      returned: always
      sample: '2018-11-20T01:00:00+01:00'
      type: str
    last_changed_date:
      description: The date the secret was last modified.
      returned: always
      sample: '2018-11-20T12:16:38.433000+01:00'
      type: str
    name:
      description: The secret name.
      returned: always
      sample: my_secret
      type: str
    rotation_enabled:
      description: The secret rotation status.
      returned: always
      sample: false
      type: bool
    version_ids_to_stages:
      description: Provide the secret version ids and the associated secret stage.
      returned: always
      sample:
        dc1ed59b-6d8e-4450-8b41-536dfe4600a9:
        - AWSCURRENT
      type: dict
  description: The secret information
  returned: always
  type: complex