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 alinabuzachis committed Oct 24, 2024
1 parent 087b5b9 commit d183b40
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions plugins/modules/ec2_vpc_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
---
module: ec2_vpc_vpn
version_added: 1.0.0
short_description: Create, modify, and delete EC2 VPN connections.
short_description: Create, modify, and delete EC2 VPN connections
description:
- This module creates, modifies, and deletes VPN connections. Idempotence is achieved by using the filters
option or specifying the VPN connection identifier.
extends_documentation_fragment:
- amazon.aws.ec2
- amazon.aws.aws
author: "Sloane Hertel (@s-hertel)"
- amazon.aws.ec2
- amazon.aws.aws
- amazon.aws.tags.deprecated_purge
author:
- "Sloane Hertel (@s-hertel)"
options:
state:
description:
Expand All @@ -44,15 +46,6 @@
description:
- The ID of the VPN connection. Required to modify or delete a connection if the filters option does not provide a unique match.
type: str
tags:
description:
- Tags to attach to the VPN connection.
type: dict
purge_tags:
description:
- Whether or not to delete VPN connections tags that are associated with the connection but not specified in the task.
type: bool
default: false
static_only:
description:
- Indicates whether the VPN connection uses static routes only. Static routes must be used for devices that don't support BGP.
Expand Down Expand Up @@ -580,8 +573,12 @@ def check_for_update(connection, module_params, vpn_connection_id):

# Get changes to tags
current_tags = boto3_tag_list_to_ansible_dict(current_attrs.get('tags', []), u'key', u'value')
tags_to_add, changes['tags_to_remove'] = compare_aws_tags(current_tags, tags, purge_tags)
changes['tags_to_add'] = ansible_dict_to_boto3_tag_list(tags_to_add)
if tags is None:
changes['tags_to_remove'] = []
changes['tags_to_add'] = []
else:
tags_to_add, changes['tags_to_remove'] = compare_aws_tags(current_tags, tags, purge_tags)
changes['tags_to_add'] = ansible_dict_to_boto3_tag_list(tags_to_add)
# Get changes to routes
if 'Routes' in vpn_connection:
current_routes = [route['DestinationCidrBlock'] for route in vpn_connection['Routes']]
Expand Down Expand Up @@ -766,13 +763,13 @@ def main():
state=dict(type='str', default='present', choices=['present', 'absent']),
filters=dict(type='dict', default={}),
vpn_gateway_id=dict(type='str'),
tags=dict(default={}, type='dict'),
tags=dict(type='dict', aliases=['resource_tags']),
connection_type=dict(default='ipsec.1', type='str'),
tunnel_options=dict(no_log=True, type='list', default=[], elements='dict'),
static_only=dict(default=False, type='bool'),
customer_gateway_id=dict(type='str'),
vpn_connection_id=dict(type='str'),
purge_tags=dict(type='bool', default=False),
purge_tags=dict(type='bool'),
routes=dict(type='list', default=[], elements='str'),
purge_routes=dict(type='bool', default=False),
wait_timeout=dict(type='int', default=600),
Expand All @@ -782,6 +779,14 @@ def main():
supports_check_mode=True)
connection = module.client('ec2', retry_decorator=VPNRetry.jittered_backoff(retries=10))

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

state = module.params.get('state')
parameters = dict(module.params)

Expand Down

0 comments on commit d183b40

Please sign in to comment.