Skip to content

Commit

Permalink
Fix performance_insights_kms_key_id snake case variation (#2219)
Browse files Browse the repository at this point in the history
SUMMARY
performance_insights_kms_key_id parameter has a variation in AWS snake case
Fixes #2217
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
rds_instance - parameter: performance_insights_kms_key_id
ADDITIONAL INFORMATION
I have successfully created an rds_instance instance w/ correct custom performance_insights_kms_key_id (not the default: "aws/rds")

Reviewed-by: Mark Chappell
Reviewed-by: Gabriel PREDA
Reviewed-by: Alina Buzachis
  • Loading branch information
eRadical authored Aug 22, 2024
1 parent 0dbac7a commit 1f65ad9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- rds_instance - snake case for parameter ``performance_insights_kms_key_id`` was incorrect according to boto documentation (https://github.com/ansible-collections/amazon.aws/pull/2163).
11 changes: 9 additions & 2 deletions plugins/module_utils/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def get_snapshot(client, snapshot_identifier: str, snapshot_type: str, convert_t
snapshot = snapshots[0]

if snapshot and convert_tags:
snapshot["Tags"] = boto3_tag_list_to_ansible_dict(snapshot.pop("TagList"))
snapshot["Tags"] = boto3_tag_list_to_ansible_dict(snapshot.pop("TagList", None))

return snapshot

Expand Down Expand Up @@ -576,8 +576,15 @@ def arg_spec_to_rds_params(options_dict: Dict[str, Any]) -> Dict[str, Any]:
has_processor_features = True
processor_features = options_dict.pop("processor_features")
camel_options = snake_dict_to_camel_dict(options_dict, capitalize_first=True)
aws_replace_keys = (
("Db", "DB"),
("Iam", "IAM"),
("Az", "AZ"),
("Ca", "CA"),
("PerformanceInsightsKmsKeyId", "PerformanceInsightsKMSKeyId"),
)
for key in list(camel_options.keys()):
for old, new in (("Db", "DB"), ("Iam", "IAM"), ("Az", "AZ"), ("Ca", "CA")):
for old, new in aws_replace_keys:
if old in key:
camel_options[key.replace(old, new)] = camel_options.pop(key)
camel_options["Tags"] = tags
Expand Down
8 changes: 8 additions & 0 deletions plugins/modules/rds_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,14 @@ def get_options_with_changing_values(client, module: AnsibleAWSModule, parameter
# must be always specified when changing iops
parameters["AllocatedStorage"] = new_allocated_storage

instance_performance_insights_kms_key_id = instance.get("PerformanceInsightsKMSKeyId")
if instance_performance_insights_kms_key_id == module.params.get(
"performance_insights_kms_key_id"
) or instance_performance_insights_kms_key_id.split("/")[-1] == module.params.get(
"performance_insights_kms_key_id"
):
parameters.pop("PerformanceInsightsKMSKeyId", None)

if parameters.get("NewDBInstanceIdentifier") and instance.get("PendingModifiedValues", {}).get(
"DBInstanceIdentifier"
):
Expand Down

0 comments on commit 1f65ad9

Please sign in to comment.