Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rds_cluster: add support for I/O-Optimized storage configuration for aurora clusters #2063

Original file line number Diff line number Diff line change
@@ -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).
24 changes: 21 additions & 3 deletions plugins/modules/rds_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
mandar242 marked this conversation as resolved.
Show resolved Hide resolved
version_added: 5.5.0
iops:
description:
Expand Down Expand Up @@ -1100,6 +1104,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]

Expand Down Expand Up @@ -1237,7 +1245,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"),
Expand Down Expand Up @@ -1324,6 +1332,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"])

Expand Down
44 changes: 42 additions & 2 deletions tests/integration/targets/rds_cluster_create/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,50 @@
that:
- not _result_create_db_cluster.changed

# aurora-iopt1 test
mandar242 marked this conversation as resolved.
Show resolved Hide resolved
- 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"
Loading