From f630a5121eac65b302aa96b44757754d1c148837 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 06:11:46 +0000 Subject: [PATCH] rds_cluster: state change fix (#2215) (#2252) This is a backport of PR #2215 as merged into main (7e8aad3). SUMMARY Fixes #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: Mark Chappell --- .../2214-rds_cluster-limit-params-sent-to-api-for-states.yml | 3 +++ plugins/modules/rds_cluster.py | 4 ++++ tests/integration/targets/rds_cluster_states/tasks/main.yml | 2 ++ 3 files changed, 9 insertions(+) create mode 100644 changelogs/fragments/2214-rds_cluster-limit-params-sent-to-api-for-states.yml diff --git a/changelogs/fragments/2214-rds_cluster-limit-params-sent-to-api-for-states.yml b/changelogs/fragments/2214-rds_cluster-limit-params-sent-to-api-for-states.yml new file mode 100644 index 00000000000..7ff50c509b4 --- /dev/null +++ b/changelogs/fragments/2214-rds_cluster-limit-params-sent-to-api-for-states.yml @@ -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). diff --git a/plugins/modules/rds_cluster.py b/plugins/modules/rds_cluster.py index 65ec1b849e5..bff16de087c 100644 --- a/plugins/modules/rds_cluster.py +++ b/plugins/modules/rds_cluster.py @@ -1116,11 +1116,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 diff --git a/tests/integration/targets/rds_cluster_states/tasks/main.yml b/tests/integration/targets/rds_cluster_states/tasks/main.yml index 49a37561c00..699cba9a166 100644 --- a/tests/integration/targets/rds_cluster_states/tasks/main.yml +++ b/tests/integration/targets/rds_cluster_states/tasks/main.yml @@ -16,6 +16,7 @@ username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true + backup_retention_period: 3 register: _result_delete_db_cluster - ansible.builtin.assert: @@ -31,6 +32,7 @@ engine_mode: provisioned username: "{{ username }}" password: "{{ password }}" + backup_retention_period: 3 register: _result_create_source_db_cluster - ansible.builtin.assert: