rds - create, delete, or modify an Amazon rds instance

New in version 1.3.

Synopsis

  • Creates, deletes, or modifies rds instances. 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. The ‘promote’ command requires boto >= 2.18.0. Certain features such as tags rely on boto.rds2 (boto >= 2.26.0)

Requirements (on host that executes module)

  • boto
  • python >= 2.6

Options

parameter required default choices comments
apply_immediately
no
  • yes
  • no
Used only when command=modify. If enabled, the modifications will be applied as soon as possible rather than waiting for the next preferred maintenance window.
aws_access_key
no
AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used.
aliases: ec2_access_key, access_key
aws_secret_key
no
AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used.
aliases: ec2_secret_key, secret_key
backup_retention
no
Number of days backups are retained. Set to 0 to disable backups. Default is 1 day. Valid range: 0-35. Used only when command=create or command=modify.
backup_window
no
Backup window in format of hh24:mi-hh24:mi. If not specified then a random backup window is assigned. Used only when command=create or command=modify.
character_set_name
(added in 1.9)
no
Associate the DB instance with a specified character set. Used with command=create.
command
yes
  • create
  • replicate
  • delete
  • facts
  • modify
  • promote
  • snapshot
  • reboot
  • restore
Specifies the action to take. The 'reboot' option is available starting at version 2.0
db_engine
no
  • mariadb
  • MySQL
  • oracle-se1
  • oracle-se2
  • oracle-se
  • oracle-ee
  • sqlserver-ee
  • sqlserver-se
  • sqlserver-ex
  • sqlserver-web
  • postgres
  • aurora
The type of database. Used only when command=create.
mariadb was added in version 2.2
db_name
no
Name of a database to create within the instance. If not specified then no database is created. Used only when command=create.
ec2_url
no
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.
engine_version
no
Version number of the database engine to use. Used only when command=create. If not specified then the current Amazon RDS default engine version is used
force_failover
(added in 2.0)
no no
  • yes
  • no
Used only when command=reboot. If enabled, the reboot is done using a MultiAZ failover.
instance_name
no
Database instance identifier. Required except when using command=facts or command=delete on just a snapshot
instance_type
no
The instance type of the database. Must be specified when command=create. Optional when command=replicate, command=modify or command=restore. If not specified then the replica inherits the same instance type as the source instance.
iops
no
Specifies the number of IOPS for the instance. Used only when command=create or command=modify. Must be an integer greater than 1000.
license_model
no
  • license-included
  • bring-your-own-license
  • general-public-license
  • postgresql-license
The license model for this DB instance. Used only when command=create or command=restore.
maint_window
no
Maintenance window in format of ddd:hh24:mi-ddd:hh24:mi. (Example: Mon:22:00-Mon:23:15) If not specified then a random maintenance window is assigned. Used only when command=create or command=modify.
multi_zone
no
  • yes
  • no
Specifies if this is a Multi-availability-zone deployment. Can not be used in conjunction with zone parameter. Used only when command=create or command=modify.
new_instance_name
(added in 1.5)
no
Name to rename an instance to. Used only when command=modify.
option_group
no
The name of the option group to use. If not specified then the default option group is used. Used only when command=create.
parameter_group
no
Name of the DB parameter group to associate with this instance. If omitted then the RDS default DBParameterGroup will be used. Used only when command=create or command=modify.
password
no
Password for the master database username. Used only when command=create or command=modify.
port
no 3306 for mysql, 1521 for Oracle, 1433 for SQL Server, 5432 for PostgreSQL.
Port number that the DB instance uses for connections. Used only when command=create or command=replicate.
Prior to 2.0 it always defaults to null and the API would use 3306, it had to be set to other DB default values when not using MySql. Starting at 2.0 it automatically defaults to what is expected for each db_engine.
profile
(added in 1.6)
no
Uses a boto profile. Only works with boto >= 2.24.0.
publicly_accessible
(added in 1.9)
no
explicitly set whether the resource should be publicly accessible or not. Used with command=create, command=replicate. Requires boto >= 2.26.0
region
yes
The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used.
aliases: aws_region, ec2_region
security_groups
no
Comma separated list of one or more security groups. Used only when command=create or command=modify.
security_token
(added in 1.6)
no
AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.
aliases: access_token
size
no
Size in gigabytes of the initial storage for the DB instance. Used only when command=create or command=modify.
snapshot
no
Name of snapshot to take. When command=delete, if no snapshot name is provided then no snapshot is taken. If used with command=delete with no instance_name, the snapshot is deleted. Used with command=facts, command=delete or command=snapshot.
source_instance
no
Name of the database to replicate. Used only when command=replicate.
subnet
no
VPC subnet group. If specified then a VPC instance is created. Used only when command=create.
tags
(added in 1.9)
no
tags dict to apply to a resource. Used with command=create, command=replicate, command=restore. Requires boto >= 2.26.0
upgrade
no
  • yes
  • no
Indicates that minor version upgrades should be applied automatically. Used only when command=create or command=replicate.
username
no
Master database username. Used only when command=create.
validate_certs
(added in 1.5)
no yes
  • yes
  • no
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
vpc_security_groups
no
Comma separated list of one or more vpc security group ids. Also requires `subnet` to be specified. Used only when command=create or command=modify.
wait
no no
  • yes
  • no
When command=create, replicate, modify or restore then wait for the database to enter the 'available' state. When command=delete wait for the database to be terminated.
wait_timeout
no 300
how long before wait gives up, in seconds
zone
no
availability zone in which to launch the instance. Used only when command=create, command=replicate or command=restore.
aliases: aws_zone, ec2_zone

Examples

# Basic mysql provisioning example
- 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

# Create a read-only replica and wait for it to become available
- rds:
    command: replicate
    instance_name: new-database-replica
    source_instance: new_database
    wait: yes
    wait_timeout: 600

# Delete an instance, but create a snapshot before doing so
- rds:
    command: delete
    instance_name: new-database
    snapshot: new_database_snapshot

# Get facts about an instance
- rds:
    command: facts
    instance_name: new-database
  register: new_database_facts

# Rename an instance and wait for the change to take effect
- rds:
    command: modify
    instance_name: new-database
    new_instance_name: renamed-database
    wait: yes

# Reboot an instance and wait for it to become available again
- rds:
    command: reboot
    instance_name: database
    wait: yes

# 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
- local_action:
     module: 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

- local_action:
     module: rds
     command: modify
     instance_name: MyNewInstanceName
     region: us-west-2
     vpc_security_groups: sg-xxx945xx

- debug:
    msg: "The new db endpoint is {{ rds.instance.endpoint }}"

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

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

Notes

Note

  • If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence AWS_URL or EC2_URL, AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY or EC2_ACCESS_KEY, AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY or EC2_SECRET_KEY, AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN, AWS_REGION or EC2_REGION
  • Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See http://boto.readthedocs.org/en/latest/boto_config_tut.html
  • AWS_REGION or EC2_REGION can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file

Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/rds_module.html