Skip to content

Commit

Permalink
rds_cluster: state change fix (ansible-collections#2215)
Browse files Browse the repository at this point in the history
SUMMARY

Fixes ansible-collections#2197
Limit params sent to api call to DBClusterIdentifier when using state started or stopped as
start_db_cluster and start_db_cluster supports only DBClusterIdentifier
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/start_db_cluster.html
https://boto3.amazonaws.com/v1/documentation/api/1.26.120/reference/services/rds/client/stop_db_cluster.html

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

rds_cluster
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
Reviewed-by: Mark Chappell
  • Loading branch information
mandar242 authored Aug 27, 2024
1 parent e7db692 commit 7e8aad3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- rds_cluster - Limit params sent to api call to DBClusterIdentifier when using state started or stopped (https://github.com/ansible-collections/amazon.aws/issues/2197).
4 changes: 4 additions & 0 deletions plugins/modules/rds_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,11 +1124,15 @@ def changing_cluster_options(modify_params, current_cluster):
if module.params["state"] == "started":
if current_cluster["Engine"] in ["mysql", "postgres"]:
module.fail_json("Only aurora clusters can use the state started")
# start_db_cluster supports only DBClusterIdentifier
changing_params = {}
changing_params["DBClusterIdentifier"] = db_cluster_id

if module.params["state"] == "stopped":
if current_cluster["Engine"] in ["mysql", "postgres"]:
module.fail_json("Only aurora clusters can use the state stopped")
# stop_db_cluster supports only DBClusterIdentifier
changing_params = {}
changing_params["DBClusterIdentifier"] = db_cluster_id

return changing_params
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/rds_cluster_states/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
username: "{{ username }}"
password: "{{ password }}"
skip_final_snapshot: true
backup_retention_period: 3
register: _result_delete_db_cluster

- ansible.builtin.assert:
Expand All @@ -31,6 +32,7 @@
engine_mode: provisioned
username: "{{ username }}"
password: "{{ password }}"
backup_retention_period: 3
register: _result_create_source_db_cluster

- ansible.builtin.assert:
Expand Down

0 comments on commit 7e8aad3

Please sign in to comment.