Skip to content

Commit

Permalink
rds - add the engine_mode parameter (ansible-collections#941)
Browse files Browse the repository at this point in the history
rds - add the engine_mode parameter

Depends-On: ansible-collections#1185
Add a new engine_mode parameter to rds_cluster and also adjust the test-suite follow-up to some recent API changes:

With the aurora engine, engine_mode default now on serverless.
We cannot adjust the endpoint_port of a serverless cluster.
aurora clusters are now encrypted by default (storage_encrypted)

The new engine_mode parameter also allows us to re-enable the  Aurora test of the rds_instance integration tests.

Reviewed-by: Gonéri Le Bouder <[email protected]>
Reviewed-by: Alina Buzachis <None>
  • Loading branch information
alinabuzachis committed Apr 27, 2023
1 parent 67bc04d commit 965cc45
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 45 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/rds_cluster_engine_mode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "rds_cluster - New the engine_mode parameter (https://github.com/ansible-collections/amazon.aws/pull/941)."
36 changes: 35 additions & 1 deletion plugins/modules/rds_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,27 @@
engine:
description:
- The name of the database engine to be used for this DB cluster. This is required to create a cluster.
- The combinaison of I(engine) and I(engine_mode) may not be supported.
- "See AWS documentation for details:
L(Amazon RDS Documentation,https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html)."
choices:
- aurora
- aurora-mysql
- aurora-postgresql
type: str
engine_mode:
description:
- The DB engine mode of the DB cluster. The combinaison of I(engine) and I(engine_mode) may not be supported.
- "See AWS documentation for details:
L(Amazon RDS Documentation,https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html)."
choices:
- provisioned
- serverless
- parallelquery
- global
- multimaster
type: str
version_added: 5.1.0
engine_version:
description:
- The version number of the database engine to use.
Expand Down Expand Up @@ -388,6 +404,23 @@
username: "{{ username }}"
cluster_id: "cluster-{{ resource_prefix }}-restored"
snapshot_identifier: "cluster-{{ resource_prefix }}-snapshot"
- name: Create an Aurora PostgreSQL cluster and attach an intance
amazon.aws.rds_cluster:
state: present
engine: aurora-postgresql
engine_mode: provisioned
cluster_id: '{{ cluster_id }}'
username: '{{ username }}'
password: '{{ password }}'
- name: Attach a new instance to the cluster
amazon.aws.rds_instance:
id: '{{ instance_id }}'
cluster_id: '{{ cluster_id }}'
engine: aurora-postgresql
state: present
db_instance_class: 'db.t3.medium'
'''

RETURN = r'''
Expand Down Expand Up @@ -668,7 +701,7 @@ def get_create_options(params_dict):
'AvailabilityZones', 'BacktrackWindow', 'BackupRetentionPeriod', 'PreferredBackupWindow',
'CharacterSetName', 'DBClusterIdentifier', 'DBClusterParameterGroupName', 'DBSubnetGroupName',
'DatabaseName', 'EnableCloudwatchLogsExports', 'EnableIAMDatabaseAuthentication', 'KmsKeyId',
'Engine', 'EngineVersion', 'PreferredMaintenanceWindow', 'MasterUserPassword', 'MasterUsername',
'Engine', 'EngineMode', 'EngineVersion', 'PreferredMaintenanceWindow', 'MasterUserPassword', 'MasterUsername',
'OptionGroupName', 'Port', 'ReplicationSourceIdentifier', 'SourceRegion', 'StorageEncrypted',
'Tags', 'VpcSecurityGroupIds', 'EngineMode', 'ScalingConfiguration', 'DeletionProtection',
'EnableHttpEndpoint', 'CopyTagsToSnapshot', 'Domain', 'DomainIAMRoleName',
Expand Down Expand Up @@ -923,6 +956,7 @@ def main():
enable_global_write_forwarding=dict(type='bool'),
enable_iam_database_authentication=dict(type='bool'),
engine=dict(choices=["aurora", "aurora-mysql", "aurora-postgresql"]),
engine_mode=dict(choices=["provisioned", "serverless", "parallelquery", "global", "multimaster"]),
engine_version=dict(),
final_snapshot_identifier=dict(),
force_backtrack=dict(type='bool'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
- "'engine' in _result_create_db_cluster"
- _result_create_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_db_cluster"
- _result_create_db_cluster.engine_mode == "provisioned"
- _result_create_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_db_cluster"
- "'master_username' in _result_create_db_cluster"
- _result_create_db_cluster.master_username == "{{ username }}"
- "'port' in _result_create_db_cluster"
- _result_create_db_cluster.port == {{ port }}
- "'status' in _result_create_db_cluster"
- _result_create_db_cluster.status == 'available'
- _result_create_db_cluster.storage_encrypted == false
- _result_create_db_cluster.storage_encrypted == true
- "'tags' in _result_create_db_cluster"
- _result_create_db_cluster.tags | length == 2
- _result_create_db_cluster.tags["Created_By"] == "{{ tags_create["Created_By"]}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@
- "'engine' in _result_create_db_cluster"
- _result_create_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_db_cluster"
- _result_create_db_cluster.engine_mode == "provisioned"
- _result_create_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_db_cluster"
- "'master_username' in _result_create_db_cluster"
- _result_create_db_cluster.master_username == "{{ username }}"
- "'port' in _result_create_db_cluster"
- _result_create_db_cluster.port == {{ port }}
- "'status' in _result_create_db_cluster"
- _result_create_db_cluster.status == 'available'
- _result_create_db_cluster.storage_encrypted == false
- _result_create_db_cluster.storage_encrypted == true
- "'tags' in _result_create_db_cluster"
- "'vpc_security_groups' in _result_create_db_cluster"
- _result_create_db_cluster.vpc_security_groups | selectattr('status', 'in',
Expand Down Expand Up @@ -126,15 +126,15 @@
- "'engine' in _result_create_db_cluster"
- _result_create_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_db_cluster"
- _result_create_db_cluster.engine_mode == "provisioned"
- _result_create_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_db_cluster"
- "'master_username' in _result_create_db_cluster"
- _result_create_db_cluster.master_username == "{{ username }}"
- "'port' in _result_create_db_cluster"
- _result_create_db_cluster.port == {{ port }}
- "'status' in _result_create_db_cluster"
- _result_create_db_cluster.status == 'available'
- _result_create_db_cluster.storage_encrypted == false
- _result_create_db_cluster.storage_encrypted == true
- "'tags' in _result_create_db_cluster"
- "'vpc_security_groups' in _result_create_db_cluster"
- _result_create_db_cluster.vpc_security_groups | selectattr('status', 'in',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
- not _result_delete_db_cluster.changed
ignore_errors: yes

- name: Create a DB cluster
# Follow up to Aurora Serverless V2 release, we use an aurora-mysql to
# avoid the following error when we try to adjust the port:
# You currently can't modify EndpointPort with Aurora Serverless.
- name: Create an Aurora-MySQL DB cluster
rds_cluster:
id: '{{ cluster_id }}'
state: present
engine: '{{ engine }}'
engine: aurora-mysql
engine_mode: provisioned
username: '{{ username }}'
password: '{{ password }}'
register: _result_create_source_db_cluster
Expand All @@ -37,7 +41,7 @@
- "'db_cluster_resource_id' in _result_create_source_db_cluster"
- "'endpoint' in _result_create_source_db_cluster"
- "'engine' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine == "{{ engine }}"
- _result_create_source_db_cluster.engine == "aurora-mysql"
- "'engine_mode' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine_mode == "provisioned"
- "'engine_version' in _result_create_source_db_cluster"
Expand Down Expand Up @@ -72,7 +76,7 @@
- "'db_cluster_resource_id' in _result_modify_password"
- "'endpoint' in _result_modify_password"
- "'engine' in _result_modify_password"
- _result_modify_password.engine == "{{ engine }}"
- _result_modify_password.engine == "aurora-mysql"
- "'engine_mode' in _result_modify_password"
- _result_modify_password.engine_mode == "provisioned"
- "'engine_version' in _result_modify_password"
Expand Down Expand Up @@ -105,7 +109,7 @@
- "'db_cluster_resource_id' in _result_modify_port"
- "'endpoint' in _result_modify_port"
- "'engine' in _result_modify_port"
- _result_modify_port.engine == "{{ engine }}"
- _result_modify_port.engine == "aurora-mysql"
- "'engine_mode' in _result_modify_port"
- _result_modify_port.engine_mode == "provisioned"
- "'engine_version' in _result_modify_port"
Expand Down Expand Up @@ -140,7 +144,7 @@
- "'db_cluster_resource_id' in _result_modify_id"
- "'endpoint' in _result_modify_id"
- "'engine' in _result_modify_id"
- _result_modify_id.engine == "{{ engine }}"
- _result_modify_id.engine == "aurora-mysql"
- "'engine_mode' in _result_modify_id"
- _result_modify_id.engine_mode == "provisioned"
- "'engine_version' in _result_modify_id"
Expand All @@ -167,7 +171,7 @@

- name: Create DB cluster parameter group if not exists
command: aws rds create-db-cluster-parameter-group --db-cluster-parameter-group-name
{{ new_db_parameter_group_name }} --db-parameter-group-family aurora5.6 --description
{{ new_db_parameter_group_name }} --db-parameter-group-family aurora-mysql5.7 --description
"Test DB cluster parameter group"
environment:
AWS_ACCESS_KEY_ID: '{{ aws_access_key }}'
Expand Down Expand Up @@ -199,7 +203,7 @@
- "'db_cluster_resource_id' in _result_modify_db_parameter_group_name"
- "'endpoint' in _result_modify_db_parameter_group_name"
- "'engine' in _result_modify_db_parameter_group_name"
- _result_modify_db_parameter_group_name.engine == "{{ engine }}"
- _result_modify_db_parameter_group_name.engine == "aurora-mysql"
- "'engine_mode' in _result_modify_db_parameter_group_name"
- _result_modify_db_parameter_group_name.engine_mode == "provisioned"
- "'engine_version' in _result_modify_db_parameter_group_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
- "'engine' in _result_create_src_db_cluster"
- _result_create_src_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_src_db_cluster"
- _result_create_src_db_cluster.engine_mode == "provisioned"
- _result_create_src_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_src_db_cluster"
- "'master_username' in _result_create_src_db_cluster"
- _result_create_src_db_cluster.master_username == "{{ username }}"
Expand Down Expand Up @@ -103,7 +103,7 @@
- "'engine' in _result_create_replica_db_cluster"
- _result_create_replica_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_replica_db_cluster"
- _result_create_replica_db_cluster.engine_mode == "provisioned"
- _result_create_replica_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_replica_db_cluster"
- "'master_username' in _result_create_replica_db_cluster"
- _result_create_replica_db_cluster.master_username == "{{ username }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
- "'engine' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine_mode == "provisioned"
- _result_create_source_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_source_db_cluster"
- "'master_username' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.master_username == "{{ username }}"
- "'port' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.port == {{ port }}
- "'status' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.status == 'available'
- _result_create_source_db_cluster.storage_encrypted == false
- _result_create_source_db_cluster.storage_encrypted == true
- "'tags' in _result_create_source_db_cluster"
- "'vpc_security_groups' in _result_create_source_db_cluster"

Expand Down Expand Up @@ -83,7 +83,7 @@
- "'engine' in _result_restored_db_cluster"
- _result_restored_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_restored_db_cluster"
- _result_restored_db_cluster.engine_mode == "provisioned"
- _result_restored_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_restored_db_cluster"
- "'master_username' in _result_restored_db_cluster"
- _result_restored_db_cluster.master_username == "{{ username }}"
Expand Down Expand Up @@ -152,7 +152,7 @@
- "'engine' in _result_restored_db_cluster"
- _result_restored_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_restored_db_cluster"
- _result_restored_db_cluster.engine_mode == "provisioned"
- _result_restored_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_restored_db_cluster"
- "'master_username' in _result_restored_db_cluster"
- _result_restored_db_cluster.master_username == "{{ username }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
- "'engine' in _result_create_db_cluster"
- _result_create_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_db_cluster"
- _result_create_db_cluster.engine_mode == "provisioned"
- _result_create_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_db_cluster"
- "'master_username' in _result_create_db_cluster"
- _result_create_db_cluster.master_username == "{{ username }}"
- "'port' in _result_create_db_cluster"
- _result_create_db_cluster.port == {{ port }}
- "'status' in _result_create_db_cluster"
- _result_create_db_cluster.status == 'available'
- _result_create_db_cluster.storage_encrypted == false
- _result_create_db_cluster.storage_encrypted == true
- "'tags' in _result_create_db_cluster"
- _result_create_db_cluster.tags | length == 2
- _result_create_db_cluster.tags["Created_By"] == "{{ tags_create["Created_By"]
Expand Down Expand Up @@ -81,15 +81,15 @@
- "'engine' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine_mode == "provisioned"
- _result_tag_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_tag_db_cluster"
- "'master_username' in _result_tag_db_cluster"
- _result_tag_db_cluster.master_username == "{{ username }}"
- "'port' in _result_tag_db_cluster"
- _result_tag_db_cluster.port == {{ port }}
- "'status' in _result_tag_db_cluster"
- _result_tag_db_cluster.status == 'available'
- _result_tag_db_cluster.storage_encrypted == false
- _result_tag_db_cluster.storage_encrypted == true
- "'tags' in _result_tag_db_cluster"
- _result_tag_db_cluster.tags | length == 2
- _result_tag_db_cluster.tags["Created_By"] == "{{ tags_create["Created_By"]
Expand Down Expand Up @@ -120,15 +120,15 @@
- "'engine' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine_mode == "provisioned"
- _result_tag_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_tag_db_cluster"
- "'master_username' in _result_tag_db_cluster"
- _result_tag_db_cluster.master_username == "{{ username }}"
- "'port' in _result_tag_db_cluster"
- _result_tag_db_cluster.port == {{ port }}
- "'status' in _result_tag_db_cluster"
- _result_tag_db_cluster.status == 'available'
- _result_tag_db_cluster.storage_encrypted == false
- _result_tag_db_cluster.storage_encrypted == true
- "'tags' in _result_tag_db_cluster"
- _result_tag_db_cluster.tags | length == 2
- _result_tag_db_cluster.tags["Name"] == "{{ tags_patch['Name'] }}"
Expand Down Expand Up @@ -175,15 +175,15 @@
- "'engine' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine_mode == "provisioned"
- _result_tag_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_tag_db_cluster"
- "'master_username' in _result_tag_db_cluster"
- _result_tag_db_cluster.master_username == "{{ username }}"
- "'port' in _result_tag_db_cluster"
- _result_tag_db_cluster.port == {{ port }}
- "'status' in _result_tag_db_cluster"
- _result_tag_db_cluster.status == 'available'
- _result_tag_db_cluster.storage_encrypted == false
- _result_tag_db_cluster.storage_encrypted == true
- "'tags' in _result_tag_db_cluster"
- _result_tag_db_cluster.tags | length == 1
- _result_tag_db_cluster.tags["Created_By"] == "Ansible_rds_cluster_integration_test"
Expand Down Expand Up @@ -230,15 +230,15 @@
- "'engine' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine_mode == "provisioned"
- _result_tag_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_tag_db_cluster"
- "'master_username' in _result_tag_db_cluster"
- _result_tag_db_cluster.master_username == "{{ username }}"
- "'port' in _result_tag_db_cluster"
- _result_tag_db_cluster.port == {{ port }}
- "'status' in _result_tag_db_cluster"
- _result_tag_db_cluster.status == 'available'
- _result_tag_db_cluster.storage_encrypted == false
- _result_tag_db_cluster.storage_encrypted == true
- "'tags' in _result_tag_db_cluster"
- _result_tag_db_cluster.tags | length == 2
- _result_tag_db_cluster.tags["Created_By"] == "{{ tags_create["Created_By"]}}"
Expand Down Expand Up @@ -269,15 +269,15 @@
- "'engine' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_tag_db_cluster"
- _result_tag_db_cluster.engine_mode == "provisioned"
- _result_tag_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_tag_db_cluster"
- "'master_username' in _result_tag_db_cluster"
- _result_tag_db_cluster.master_username == "{{ username }}"
- "'port' in _result_tag_db_cluster"
- _result_tag_db_cluster.port == {{ port }}
- "'status' in _result_tag_db_cluster"
- _result_tag_db_cluster.status == 'available'
- _result_tag_db_cluster.storage_encrypted == false
- _result_tag_db_cluster.storage_encrypted == true
- "'tags' in _result_tag_db_cluster"
- _result_tag_db_cluster.tags | length == 0
- "'vpc_security_groups' in _result_tag_db_cluster"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/rds_cluster_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- "'engine' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine_mode == "provisioned"
- _result_create_source_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_source_db_cluster"
- "'master_username' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.master_username == "{{ username }}"
Expand Down Expand Up @@ -149,7 +149,7 @@
- "'engine' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine == "{{ engine }}"
- "'engine_mode' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.engine_mode == "provisioned"
- _result_create_source_db_cluster.engine_mode == "serverless"
- "'engine_version' in _result_create_source_db_cluster"
- "'master_username' in _result_create_source_db_cluster"
- _result_create_source_db_cluster.master_username == "{{ username }}"
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/rds_instance_aurora/aliases
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# See: https://github.com/ansible-collections/amazon.aws/pull/1192
disabled
cloud/aws
time=30m
rds_instance
Loading

0 comments on commit 965cc45

Please sign in to comment.