diff --git a/changelogs/fragments/2063-rds_cluster-add-support-io-optimized-storage-config.yml b/changelogs/fragments/2063-rds_cluster-add-support-io-optimized-storage-config.yml new file mode 100644 index 00000000000..3ba5ff75204 --- /dev/null +++ b/changelogs/fragments/2063-rds_cluster-add-support-io-optimized-storage-config.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - rds_cluster - Add support for I/O-Optimized storage configuration for aurora clusters (https://github.com/ansible-collections/amazon.aws/pull/2063). \ No newline at end of file diff --git a/plugins/modules/rds_cluster.py b/plugins/modules/rds_cluster.py index bff16de087c..a09e5a4a799 100644 --- a/plugins/modules/rds_cluster.py +++ b/plugins/modules/rds_cluster.py @@ -187,11 +187,15 @@ description: - Specifies the storage type to be associated with the DB cluster. - This setting is required to create a Multi-AZ DB cluster. - - When specified, a value for the I(iops) parameter is required. - - Defaults to C(io1). + - For multi-AZ DB clusters, O(storage_type) defaults to V(io1) and a value for the O(iops) parameter is required. + - For Aurora DB clusters, O(storage_type) defaults to V(aurora) standard. + - For mysql and postgres DB clusters, O(storage_type) defaults to V(io1). + - Support for V(aurora) and V(aurora-iopt1) was added in release 8.1.0. type: str choices: - io1 + - aurora + - aurora-iopt1 version_added: 5.5.0 iops: description: @@ -1105,6 +1109,10 @@ def changing_cluster_options(modify_params, current_cluster): changing_params["DBClusterParameterGroupName"] = desired_db_cluster_parameter_group for param in modify_params: + # describe_db_clusters does not return StorageType for clusters with storage config as "aurora standard" + if param == "StorageType": + changing_params[param] = modify_params[param] + continue if modify_params[param] != current_cluster[param]: changing_params[param] = modify_params[param] @@ -1246,7 +1254,7 @@ def main(): engine_mode=dict(choices=["provisioned", "serverless", "parallelquery", "global", "multimaster"]), engine_version=dict(), allocated_storage=dict(type="int"), - storage_type=dict(type="str", choices=["io1"]), + storage_type=dict(type="str", choices=["io1", "aurora", "aurora-iopt1"]), iops=dict(type="int"), final_snapshot_identifier=dict(), force_backtrack=dict(type="bool"), @@ -1333,6 +1341,16 @@ def main(): if not module.params.get("storage_type"): module.params["storage_type"] = "io1" + if module.params.get("engine") and module.params["engine"] in ("aurora", "aurora-mysql", "aurora-postgresql"): + if not module.check_mode and module.params.get("storage_type"): + module.params["storage_type"] = "aurora" + + if module.params.get("storage_type") and module.params["storage_type"] in ("aurora", "aurora-iopt1"): + if module.params.get("engine") not in ("aurora", "aurora-mysql", "aurora-postgresql"): + module.fail_json( + f"storage_type={module.params['storage_type']} is only supported for aurora engines 'aurora', 'aurora-mysql', 'aurora-postgresql'" + ) + module.params["db_cluster_identifier"] = module.params["db_cluster_identifier"].lower() cluster = get_cluster(module.params["db_cluster_identifier"]) diff --git a/tests/integration/targets/rds_cluster_create/tasks/main.yaml b/tests/integration/targets/rds_cluster_create/tasks/main.yaml index 7bc8d489306..5689efbbaa5 100644 --- a/tests/integration/targets/rds_cluster_create/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_create/tasks/main.yaml @@ -118,10 +118,50 @@ that: - not _result_create_db_cluster.changed + # aurora-iopt1 test + - name: Create aurora cluster with IO optimized storage + amazon.aws.rds_cluster: + engine: "{{ engine }}" + username: "{{ username }}" + password: "{{ password }}" + cluster_id: "{{ cluster_id }}-io-optimized" + tags: "{{ tags_create }}" + storage_type: aurora-iopt1 + register: _result_create_db_cluster_io_optimized + + - assert: + that: + - _result_create_db_cluster_io_optimized.changed + # as of 5/2024, API does not return the value of storage_type when storage_type not set or set to "aurora" + # - _result_create_db_cluster_io_optimized.storage_type == 'aurora-iopt1' + - _result_create_db_cluster_io_optimized.storage_encrypted == false + - _result_create_db_cluster_io_optimized.engine_mode == "provisioned" + - _result_create_db_cluster_io_optimized.status == 'available' + + # aurora-iopt1 test failure + - name: Create mysql cluster with IO optimized storage - test failure with wrong engine + storage combination + amazon.aws.rds_cluster: + engine: mysql + username: "{{ username }}" + password: "{{ password }}" + cluster_id: "{{ cluster_id }}-io-optimized-failure" + tags: "{{ tags_create }}" + storage_type: aurora-iopt1 + register: _result_create_db_cluster_io_optimized + ignore_errors: true + + - assert: + that: + - not _result_create_db_cluster_io_optimized.changed + - _result_create_db_cluster_io_optimized.failed + always: - - name: Delete DB cluster without creating a final snapshot + - name: Delete test DB clusters without creating a final snapshot amazon.aws.rds_cluster: state: absent - cluster_id: "{{ cluster_id }}" + cluster_id: "{{ item }}" skip_final_snapshot: true ignore_errors: true + with_items: + - "{{ cluster_id }}" + - "{{ cluster_id }}-io-optimized"