ansible / ansible.builtin / v2.9.13 / module / rds create, delete, or modify Amazon rds instances, rds snapshots, and related facts | "added in version" 1.3 of ansible.builtin" Authors: Bruce Pennypacker (@bpennypacker), Will Thames (@willthames) stableinterface | supported by communityansible.builtin.rds (v2.9.13) — module
pip
Install with pip install ansible==2.9.13
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(rds_instance) instead.
# 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 }}"
iops: description: - Specifies the number of IOPS for the instance. Used only when command=create or command=modify. Must be an integer greater than 1000. port: default: 3306 for mysql, 1521 for Oracle, 1433 for SQL Server, 5432 for PostgreSQL. description: - 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 C(db_engine). size: description: - Size in gigabytes of the initial storage for the DB instance. Used only when command=create or command=modify. tags: description: - tags dict to apply to a resource. Used with command=create, command=replicate, command=restore. Requires boto >= 2.26.0 version_added: '1.9' version_added_collection: ansible.builtin wait: default: 'no' description: - 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. type: bool zone: aliases: - aws_zone - ec2_zone description: - availability zone in which to launch the instance. Used only when command=create, command=replicate or command=restore. region: aliases: - aws_region - ec2_region description: - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. required: true type: str subnet: description: - VPC subnet group. If specified then a VPC instance is created. Used only when command=create. 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 db_name: description: - Name of a database to create within the instance. If not specified then no database is created. Used only when command=create. profile: aliases: - aws_profile description: - A named AWS profile to use for authentication. - See the AWS documentation for more information about named profiles U(https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html). - The C(AWS_PROFILE) environment variable may also be used. - The I(profile) option is mutually exclusive with the I(aws_access_key), I(aws_secret_key) and I(security_token) options. type: str upgrade: default: 'no' description: - Indicates that minor version upgrades should be applied automatically. - Used only when command=create or command=modify or command=restore or command=replicate. type: bool password: description: - Password for the master database username. Used only when command=create or command=modify. snapshot: description: - 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. username: description: - Master database username. Used only when command=create. 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 command=create. - mariadb was added in version 2.2 access_key: aliases: - aws_access_key_id - aws_access_key - ec2_access_key description: - AWS access key ID. - See the AWS documentation for more information about access tokens U(https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys). - The C(AWS_ACCESS_KEY_ID), C(AWS_ACCESS_KEY) or C(EC2_ACCESS_KEY) environment variables may also be used in decreasing order of preference. - The I(aws_access_key) and I(profile) options are mutually exclusive. - The I(aws_access_key_id) alias was added in release 5.1.0 for consistency with the AWS botocore SDK. - The I(ec2_access_key) alias has been deprecated and will be removed in a release after 2024-12-01. - Support for the C(EC2_ACCESS_KEY) environment variable has been deprecated and will be removed in a release after 2024-12-01. type: str aws_config: description: - A dictionary to modify the botocore configuration. - Parameters can be found in the AWS documentation U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config). type: dict multi_zone: description: - 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. type: bool secret_key: aliases: - aws_secret_access_key - aws_secret_key - ec2_secret_key description: - AWS secret access key. - See the AWS documentation for more information about access tokens U(https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys). - The C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY), or C(EC2_SECRET_KEY) environment variables may also be used in decreasing order of preference. - The I(secret_key) and I(profile) options are mutually exclusive. - The I(aws_secret_access_key) alias was added in release 5.1.0 for consistency with the AWS botocore SDK. - The I(ec2_secret_key) alias has been deprecated and will be removed in a release after 2024-12-01. - Support for the C(EC2_SECRET_KEY) environment variable has been deprecated and will be removed in a release after 2024-12-01. type: str endpoint_url: aliases: - ec2_url - aws_endpoint_url - s3_url description: - URL to connect to instead of the default AWS endpoints. While this can be used to connection to other AWS-compatible services the amazon.aws and community.aws collections are only tested against AWS. - The C(AWS_URL) or C(EC2_URL) environment variables may also be used, in decreasing order of preference. - The I(ec2_url) and I(s3_url) aliases have been deprecated and will be removed in a release after 2024-12-01. - Support for the C(EC2_URL) environment variable has been deprecated and will be removed in a release after 2024-12-01. type: str maint_window: description: - '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. ' option_group: description: - The name of the option group to use. If not specified then the default option group is used. Used only when command=create. wait_timeout: default: 300 description: - how long before wait gives up, in seconds aws_ca_bundle: description: - The location of a CA Bundle to use when validating SSL certificates. - The C(AWS_CA_BUNDLE) environment variable may also be used. type: path backup_window: description: - 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. instance_name: description: - Database instance identifier. Required except when using command=facts or command=delete on just a snapshot instance_type: description: - 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. 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 command=create or command=restore. session_token: aliases: - aws_session_token - security_token - aws_security_token - access_token description: - AWS STS session token for use with temporary credentials. - See the AWS documentation for more information about access tokens U(https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys). - The C(AWS_SESSION_TOKEN), C(AWS_SECURITY_TOKEN) or C(EC2_SECURITY_TOKEN) environment variables may also be used in decreasing order of preference. - The I(security_token) and I(profile) options are mutually exclusive. - Aliases I(aws_session_token) and I(session_token) were added in release 3.2.0, with the parameter being renamed from I(security_token) to I(session_token) in release 6.0.0. - The I(security_token), I(aws_security_token), and I(access_token) aliases have been deprecated and will be removed in a release after 2024-12-01. - Support for the C(EC2_SECRET_KEY) and C(AWS_SECURITY_TOKEN) environment variables has been deprecated and will be removed in a release after 2024-12-01. type: str aws_access_key: aliases: - ec2_access_key - access_key description: - AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used. aws_secret_key: aliases: - ec2_secret_key - secret_key description: - AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used. engine_version: description: - 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: default: 'no' description: - Used only when command=reboot. If enabled, the reboot is done using a MultiAZ failover. type: bool version_added: '2.0' version_added_collection: ansible.builtin validate_certs: default: true description: - When set to C(false), SSL certificates will not be validated for communication with the AWS APIs. - Setting I(validate_certs=false) is strongly discouraged, as an alternative, consider setting I(aws_ca_bundle) instead. 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 command=create or command=modify. security_groups: description: - Comma separated list of one or more security groups. Used only when command=create or command=modify. source_instance: description: - Name of the database to replicate. Used only when command=replicate. 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 command=create or command=modify. ' apply_immediately: default: 'no' description: - 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. type: bool new_instance_name: description: - Name to rename an instance to. Used only when command=modify. version_added: '1.5' version_added_collection: ansible.builtin character_set_name: description: - Associate the DB instance with a specified character set. Used with command=create. version_added: '1.9' version_added_collection: ansible.builtin publicly_accessible: description: - explicitly set whether the resource should be publicly accessible or not. Used with command=create, command=replicate. Requires boto >= 2.26.0 version_added: '1.9' version_added_collection: ansible.builtin vpc_security_groups: description: - 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. debug_botocore_endpoint_logs: default: false description: - Use a C(botocore.endpoint) logger to parse the unique (rather than total) C("resource:action") API calls made during a task, outputing the set to the resource_actions key in the task results. Use the C(aws_resource_action) callback to output to total list made during a playbook. - The C(ANSIBLE_DEBUG_BOTOCORE_LOGS) environment variable may also be used. type: bool
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