Skip to content

Commit

Permalink
rds_param_group: WARN on updating DBParameterGroupFamily (engine) (#1169
Browse files Browse the repository at this point in the history
)

rds_param_group: WARN on updating DBParameterGroupFamily (engine)

SUMMARY

Fixes #1074
Added a check to WARN the task while modifying/updating rds_param_group if task tries to change DB parameter group family.
As AWS Documentation specifies that,
The DB parameter group family can't be changed when updating a DB parameter group.


ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

rds_param_group
ADDITIONAL INFORMATION



Steps to reproduce

Create rds Param group

- name: Create a param group
  hosts: localhost
  gather_facts: false
  tasks:
    - name: create test rds db parameter group
      amazon.aws.rds_param_group:
        name: "test-parameter-group"
        description: test rpg
        state: present
        engine: "aurora-postgresql13"


Try to change engine (family), with the fix in PR task should throw warning.

- name: Create a param group
  hosts: localhost
  gather_facts: false
  tasks:
    - name: create test rds db parameter group
      amazon.aws.rds_param_group:
        name: "test-parameter-group"
        description: test rpg
        state: present
        engine: "aurora-postgresql14"

Reviewed-by: Jill R <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mandar Kulkarni <[email protected]>
  • Loading branch information
mandar242 authored Oct 20, 2022
1 parent 1de120d commit 8110a16
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- rds_param_group - added a check to fail the task while modifying/updating rds_param_group if trying to change DB parameter group family. (https://github.com/ansible-collections/amazon.aws/pull/1169).
7 changes: 7 additions & 0 deletions plugins/modules/rds_param_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
- The type of database for this group.
- Please use following command to get list of all supported db engines and their respective versions.
- '# aws rds describe-db-engine-versions --query "DBEngineVersions[].DBParameterGroupFamily"'
- The DB parameter group family is immutable and can't be changed when updating a DB parameter group.
See U(https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbparametergroup.html)
- Required for I(state=present).
type: str
immediate:
Expand Down Expand Up @@ -266,6 +268,11 @@ def ensure_present(module, connection):
module.fail_json_aws(e, msg="Couldn't create parameter group")
else:
group = response['DBParameterGroups'][0]
db_parameter_group_family = group['DBParameterGroupFamily']

if module.params.get('engine') != db_parameter_group_family:
module.warn("The DB parameter group family (engine) can't be changed when updating a DB parameter group.")

if tags:
changed = update_tags(module, connection, group, tags)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ rds_param_group:
name: '{{ resource_prefix}}rds-param-group'
description: Test group for rds_param_group Ansible module
engine: postgres9.6
engine_to_modify_to: postgres10

rds_long_param_list:
application_name: Test
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/targets/rds_param_group/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,27 @@
- result.tags["Test"] == '123'

# ============================================================

- name: test modifying rds parameter group engine/family (warning displayed)
rds_param_group:
name: '{{ rds_param_group.name }}'
engine: '{{ rds_param_group.engine_to_modify_to }}'
description: '{{ rds_param_group.description }}'
state: present
tags:
Environment: test
Test: 123
register: result

- name: verify that modifying rds param group engine/family displays warning
assert:
that:
- not result.changed
- not result.failed
- result.warnings is defined
- result.warnings | length > 0

# ============================================================
- name: test tagging existing group - CHECK_MODE
rds_param_group:
name: '{{ rds_param_group.name }}'
Expand Down

0 comments on commit 8110a16

Please sign in to comment.