Skip to content

Commit

Permalink
Tagging - remove default empty dict where purge_tags default is False (
Browse files Browse the repository at this point in the history
…ansible-collections#1186)

Tagging - remove default empty dict where purge_tags default is False

Depends-On: ansible-collections#844
SUMMARY

Deprecate purge_tags=False
Remove default of empty dict for tags

ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/aws_kms.py
plugins/modules/cloudfront_distribution.py
plugins/modules/ec2_vpc_vpn.py
plugins/modules/rds_param_group.py
ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@374bcfd
  • Loading branch information
tremble authored and goneri committed Sep 23, 2022
1 parent dd06801 commit 8e73fd4
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions plugins/modules/rds_param_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
version_added: 1.0.0
short_description: manage RDS parameter groups
description:
- Creates, modifies, and deletes RDS parameter groups.
- Creates, modifies, and deletes RDS parameter groups.
options:
state:
description:
Expand Down Expand Up @@ -48,21 +48,13 @@
or T for tera (1024^4), and these values will be expanded into the appropriate number before being set in the parameter group.
aliases: [parameters]
type: dict
tags:
description:
- Dictionary of tags to attach to the parameter group.
type: dict
purge_tags:
description:
- Whether or not to remove tags that do not appear in the C(tags) list.
type: bool
default: False
author:
- "Scott Anderson (@tastychutney)"
- "Will Thames (@willthames)"
- "Scott Anderson (@tastychutney)"
- "Will Thames (@willthames)"
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
'''

Expand Down Expand Up @@ -216,7 +208,10 @@ def update_parameters(module, connection):


def update_tags(module, connection, group, tags):
if tags is None:
return False
changed = False

existing_tags = connection.list_tags_for_resource(aws_retry=True, ResourceName=group['DBParameterGroupArn'])['TagList']
to_update, to_delete = compare_aws_tags(boto3_tag_list_to_ansible_dict(existing_tags),
tags, module.params['purge_tags'])
Expand Down Expand Up @@ -319,15 +314,23 @@ def main():
description=dict(),
params=dict(aliases=['parameters'], type='dict'),
immediate=dict(type='bool', aliases=['apply_immediately']),
tags=dict(type='dict', default={}),
purge_tags=dict(type='bool', default=False),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
)
module = AnsibleAWSModule(
argument_spec=argument_spec,
required_if=[['state', 'present', ['description', 'engine']]],
supports_check_mode=True
)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

try:
conn = module.client('rds', retry_decorator=AWSRetry.jittered_backoff())
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
Expand Down

0 comments on commit 8e73fd4

Please sign in to comment.