community.aws.rds (0.1.2) — module

create, delete, or modify Amazon rds instances, rds snapshots, and related facts

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

Authors: Bruce Pennypacker (@bpennypacker), Will Thames (@willthames)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.aws
      version: 0.1.2

Description

Creates, deletes, or modifies rds resources.

When creating an instance it can be either a new instance or a read-only replica of an existing instance.

This module has a dependency on python-boto >= 2.5 and will soon be deprecated.

The 'promote' command requires boto >= 2.18.0. Certain features such as tags rely on boto.rds2 (boto >= 2.26.0).

Please use boto3 based M(community.aws.rds_instance) instead.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Basic mysql provisioning example
  community.aws.rds:
    command: create
    instance_name: new-database
    db_engine: MySQL
    size: 10
    instance_type: db.m1.small
    username: mysql_admin
    password: 1nsecure
    tags:
      Environment: testing
      Application: cms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a read-only replica and wait for it to become available
  community.aws.rds:
    command: replicate
    instance_name: new-database-replica
    source_instance: new_database
    wait: yes
    wait_timeout: 600
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete an instance, but create a snapshot before doing so
  community.aws.rds:
    command: delete
    instance_name: new-database
    snapshot: new_database_snapshot
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get facts about an instance
  community.aws.rds:
    command: facts
    instance_name: new-database
  register: new_database_facts
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename an instance and wait for the change to take effect
  community.aws.rds:
    command: modify
    instance_name: new-database
    new_instance_name: renamed-database
    wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reboot an instance and wait for it to become available again
  community.aws.rds:
    command: reboot
    instance_name: database
    wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Restore a Postgres db instance from a snapshot, wait for it to become available again, and
#  then modify it to add your security group. Also, display the new endpoint.
#  Note that the "publicly_accessible" option is allowed here just as it is in the AWS CLI
- community.aws.rds:
    command: restore
    snapshot: mypostgres-snapshot
    instance_name: MyNewInstanceName
    region: us-west-2
    zone: us-west-2b
    subnet: default-vpc-xx441xxx
    publicly_accessible: yes
    wait: yes
    wait_timeout: 600
    tags:
        Name: pg1_test_name_tag
  register: rds
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- community.aws.rds:
    command: modify
    instance_name: MyNewInstanceName
    region: us-west-2
    vpc_security_groups: sg-xxx945xx
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    msg: "The new db endpoint is {{ rds.instance.endpoint }}"

Inputs

    
iops:
    description:
    - Specifies the number of IOPS for the instance.
    - Used only when I(command=create) or I(command=modify).
    - Must be an integer greater than 1000.
    type: str

port:
    description:
    - Port number that the DB instance uses for connections.
    - Used only when I(command=create) or I(command=replicate).
    - 'Defaults to the standard ports for each I(db_engine): C(3306) for MySQL and MariaDB,
      C(1521) for Oracle C(1433) for SQL Server, C(5432) for PostgreSQL.'
    type: int

size:
    description:
    - Size in gigabytes of the initial storage for the DB instance.
    - Used only when I(command=create) or I(command=modify).
    type: str

tags:
    description:
    - tags dict to apply to a resource.
    - Used with I(command=create), I(command=replicate), I(command=restore).
    - Requires boto >= 2.26.0
    type: dict

wait:
    default: false
    description:
    - When I(command=create), replicate, modify or restore then wait for the database
      to enter the 'available' state.
    - When I(command=delete), wait for the database to be terminated.
    type: bool

zone:
    aliases:
    - aws_zone
    - ec2_zone
    description:
    - availability zone in which to launch the instance.
    - Used only when I(command=create), I(command=replicate) or I(command=restore).
    - Can not be used in conjunction with I(multi_zone) parameter.
    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

subnet:
    description:
    - VPC subnet group.
    - If specified then a VPC instance is created.
    - Used only when I(command=create).
    type: str

command:
    choices:
    - create
    - replicate
    - delete
    - facts
    - modify
    - promote
    - snapshot
    - reboot
    - restore
    description:
    - Specifies the action to take. The 'reboot' option is available starting at version
      2.0.
    required: true
    type: str

db_name:
    description:
    - Name of a database to create within the instance.
    - If not specified then no database is created.
    - Used only when I(command=create).
    type: str

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

upgrade:
    default: false
    description:
    - Indicates that minor version upgrades should be applied automatically.
    - Used only when I(command=create) or I(command=modify) or I(command=restore) or I(command=replicate).
    type: bool

password:
    description:
    - Password for the master database username.
    - Used only when I(command=create) or I(command=modify).
    type: str

snapshot:
    description:
    - Name of snapshot to take.
    - When I(command=delete), if no I(snapshot) name is provided then no snapshot is taken.
    - When I(command=delete), if no I(instance_name) is provided the snapshot is deleted.
    - Used with I(command=facts), I(command=delete) or I(command=snapshot).
    type: str

username:
    description:
    - Master database username.
    - Used only when I(command=create).
    type: str

db_engine:
    choices:
    - mariadb
    - MySQL
    - oracle-se1
    - oracle-se2
    - oracle-se
    - oracle-ee
    - sqlserver-ee
    - sqlserver-se
    - sqlserver-ex
    - sqlserver-web
    - postgres
    - aurora
    description:
    - The type of database.
    - Used only when I(command=create).
    - mariadb was added in version 2.2.
    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

multi_zone:
    description:
    - Specifies if this is a Multi-availability-zone deployment.
    - Can not be used in conjunction with I(zone) parameter.
    - Used only when I(command=create) or I(command=modify).
    type: bool

maint_window:
    description:
    - 'Maintenance window in format of C(ddd:hh24:mi-ddd:hh24:mi).  (Example: C(Mon:22:00-Mon:23:15))'
    - Times are specified in UTC.
    - If not specified then a random maintenance window is assigned.
    - Used only when I(command=create) or I(command=modify).
    type: str

option_group:
    description:
    - The name of the option group to use.
    - If not specified then the default option group is used.
    - Used only when I(command=create).
    type: str

wait_timeout:
    default: 300
    description:
    - How long before wait gives up, in seconds.
    - Used when I(wait=true).
    type: int

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

backup_window:
    description:
    - 'Backup window in format of C(hh24:mi-hh24:mi). (Example: C(18:00-20:30))'
    - Times are specified in UTC.
    - If not specified then a random backup window is assigned.
    - Used only when command=create or command=modify.
    type: str

instance_name:
    description:
    - Database instance identifier.
    - Required except when using I(command=facts) or I(command=delete) on just a snapshot.
    type: str

instance_type:
    aliases:
    - type
    description:
    - The instance type of the database.
    - If not specified then the replica inherits the same instance type as the source
      instance.
    - Required when I(command=create).
    - Optional when I(command=replicate), I(command=modify) or I(command=restore).
    type: str

license_model:
    choices:
    - license-included
    - bring-your-own-license
    - general-public-license
    - postgresql-license
    description:
    - The license model for this DB instance.
    - Used only when I(command=create) or I(command=restore).
    type: str

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

engine_version:
    description:
    - Version number of the database engine to use.
    - If not specified then the current Amazon RDS default engine version is used
    - Used only when I(command=create).
    type: str

force_failover:
    default: false
    description:
    - If enabled, the reboot is done using a MultiAZ failover.
    - Used only when I(command=reboot).
    type: bool

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

parameter_group:
    description:
    - Name of the DB parameter group to associate with this instance.
    - If omitted then the RDS default DBParameterGroup will be used.
    - Used only when I(command=create) or I(command=modify).
    type: str

security_groups:
    description:
    - Comma separated list of one or more security groups.
    - Used only when I(command=create) or I(command=modify).
    type: str

source_instance:
    description:
    - Name of the database to replicate.
    - Used only when I(command=replicate).
    type: str

backup_retention:
    description:
    - Number of days backups are retained.
    - Set to 0 to disable backups.
    - Default is 1 day.
    - 'Valid range: 0-35.'
    - Used only when I(command=create) or I(command=modify).
    type: str

apply_immediately:
    default: false
    description:
    - When I(apply_immediately=trye), the modifications will be applied as soon as possible
      rather than waiting for the next preferred maintenance window.
    - Used only when I(command=modify).
    type: bool

new_instance_name:
    description:
    - Name to rename an instance to.
    - Used only when I(command=modify).
    type: str

character_set_name:
    description:
    - Associate the DB instance with a specified character set.
    - Used with I(command=create).
    type: str

publicly_accessible:
    description:
    - Explicitly set whether the resource should be publicly accessible or not.
    - Used with I(command=create), I(command=replicate).
    - Requires boto >= 2.26.0
    type: str

vpc_security_groups:
    description:
    - Comma separated list of one or more vpc security group ids.
    - Also requires I(subnet) to be specified.
    - Used only when I(command=create) or I(command=modify).
    elements: str
    type: list

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

instance:
  contains:
    allocated_storage:
      description: the allocated storage size in gigabytes (GB)
      returned: when RDS instance exists
      sample: '100'
      type: str
    auto_minor_version_upgrade:
      description: indicates that minor engine upgrades will be applied automatically
        to the DB instance during the maintenance window
      returned: when RDS instance exists
      sample: 'true'
      type: bool
    backup_window:
      description: the daily time range during which automated backups are created
        if automated backups are enabled
      returned: when RDS instance exists and automated backups are enabled
      sample: 03:00-03:30
      type: str
    character_set_name:
      description: the name of the character set that this instance is associated
        with
      returned: when RDS instance exists
      sample: AL32UTF8
      type: str
    db_name:
      description: the name of the database to create when the DB instance is created
      returned: when RDS instance exists
      sample: ASERTG
      type: str
    db_subnet_groups:
      contains:
        description:
          description: the subnet group associated with the DB instance
          returned: when RDS instance exists
          sample: Subnets for the UAT RDS SQL DB Instance
          type: str
        name:
          description: the name of the DB subnet group
          returned: when RDS instance exists
          sample: samplesubnetgrouprds-j6paiqkxqp4z
          type: str
        status:
          description: the status of the DB subnet group
          returned: when RDS instance exists
          sample: complete
          type: str
        subnets:
          contains:
            availability_zone:
              contains:
                name:
                  description: availability zone
                  returned: when RDS instance exists
                  sample: eu-west-1b
                  type: str
                provisioned_iops_capable:
                  description: whether provisioned iops are available in AZ subnet
                  returned: when RDS instance exists
                  sample: 'false'
                  type: bool
              description: subnet availability zone information
              returned: when RDS instance exists
              type: complex
            identifier:
              description: the identifier of the subnet
              returned: when RDS instance exists
              sample: subnet-3fdba63e
              type: str
            status:
              description: the status of the subnet
              returned: when RDS instance exists
              sample: active
              type: str
          description: the description of the DB subnet group
          returned: when RDS instance exists
          type: complex
      description: information on the subnet group associated with this RDS instance
      returned: when RDS instance exists
      type: complex
    endpoint:
      description: the endpoint uri of the database instance
      returned: when RDS instance exists
      sample: my-ansible-database.asdfaosdgih.us-east-1.rds.amazonaws.com
      type: str
    engine:
      description: the name of the database engine
      returned: when RDS instance exists
      sample: oracle-se
      type: str
    engine_version:
      description: the version of the database engine
      returned: when RDS instance exists
      sample: 11.2.0.4.v6
      type: str
    latest_restorable_time:
      description: the latest time to which a database can be restored with point-in-time
        restore
      returned: when RDS instance exists
      sample: '1489707802.0'
      type: str
    license_model:
      description: the license model information
      returned: when RDS instance exists
      sample: bring-your-own-license
      type: str
    option_groups:
      contains:
        option_group_name:
          description: the option group name for this RDS instance
          returned: when RDS instance exists
          sample: default:oracle-se-11-2
          type: str
        status:
          description: the status of the RDS instance's option group membership
          returned: when RDS instance exists
          sample: in-sync
          type: str
      description: the list of option group memberships for this RDS instance
      returned: when RDS instance exists
      type: complex
    parameter_groups:
      contains:
        parameter_apply_status:
          description: the status of parameter updates
          returned: when RDS instance exists
          sample: in-sync
          type: str
        parameter_group_name:
          description: the name of the DP parameter group
          returned: when RDS instance exists
          sample: testawsrpprodb01spfile-1ujg7nrs7sgyz
          type: str
      description: the list of DB parameter groups applied to this RDS instance
      returned: when RDS instance exists and parameter groups are defined
      type: complex
    pending_modified_values:
      contains:
        allocated_storage:
          description: the new allocated storage size for this RDS instance that will
            be applied or is in progress
          returned: when RDS instance exists
          sample: 'null'
          type: str
        backup_retention_period:
          description: the pending number of days for which automated backups are
            retained
          returned: when RDS instance exists
          sample: 'null'
          type: str
        db_instance_class:
          description: the new DB instance class for this RDS instance that will be
            applied or is in progress
          returned: when RDS instance exists
          sample: 'null'
          type: str
        db_instance_identifier:
          description: the new DB instance identifier this RDS instance that will
            be applied or is in progress
          returned: when RDS instance exists
          sample: 'null'
          type: str
        engine_version:
          description: indicates the database engine version
          returned: when RDS instance exists
          sample: 'null'
          type: str
        iops:
          description: the new provisioned IOPS value for this RDS instance that will
            be applied or is being applied
          returned: when RDS instance exists
          sample: 'null'
          type: str
        master_user_password:
          description: the pending or in-progress change of the master credentials
            for this RDS instance
          returned: when RDS instance exists
          sample: 'null'
          type: str
        multi_az:
          description: indicates that the single-AZ RDS instance is to change to a
            multi-AZ deployment
          returned: when RDS instance exists
          sample: 'null'
          type: str
        port:
          description: specifies the pending port for this RDS instance
          returned: when RDS instance exists
          sample: 'null'
          type: str
      description: a dictionary of changes to the RDS instance that are pending
      returned: when RDS instance exists
      type: complex
    port:
      description: the listening port of the database instance
      returned: when RDS instance exists
      sample: 3306
      type: int
    publicly_accessible:
      description: the accessibility options for the DB instance
      returned: when RDS instance exists
      sample: 'true'
      type: bool
    read_replica_source_dbinstance_identifier:
      description: the identifier of the source DB instance if this RDS instance is
        a read replica
      returned: when read replica RDS instance exists
      sample: 'null'
      type: str
    secondary_availability_zone:
      description: the name of the secondary AZ for a DB instance with multi-AZ support
      returned: when RDS instance exists and is multy-AZ
      sample: eu-west-1b
      type: str
  description: the rds instance
  returned: always
  type: complex