mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
module_utils/ec2: fix boto3 tags to remove (#25277)
* Fix boto3 tags to remove; unable to remove a list of strings, need list of {'Key': key} * pep8 fix * cannot bugfix due to differences in AWS APIs - just document * add more info to guidelines for using compare_aws_tags
This commit is contained in:
parent
b2b0938aff
commit
7bebc83dcf
2 changed files with 6 additions and 3 deletions
|
@ -652,13 +652,14 @@ def map_complex_type(complex_type, type_map):
|
||||||
def compare_aws_tags(current_tags_dict, new_tags_dict, purge_tags=True):
|
def compare_aws_tags(current_tags_dict, new_tags_dict, purge_tags=True):
|
||||||
"""
|
"""
|
||||||
Compare two dicts of AWS tags. Dicts are expected to of been created using 'boto3_tag_list_to_ansible_dict' helper function.
|
Compare two dicts of AWS tags. Dicts are expected to of been created using 'boto3_tag_list_to_ansible_dict' helper function.
|
||||||
Two dicts are returned - the first is tags to be set, the second is any tags to remove
|
Two dicts are returned - the first is tags to be set, the second is any tags to remove. Since the AWS APIs differ t
|
||||||
|
hese may not be able to be used out of the box.
|
||||||
|
|
||||||
:param current_tags_dict:
|
:param current_tags_dict:
|
||||||
:param new_tags_dict:
|
:param new_tags_dict:
|
||||||
:param purge_tags:
|
:param purge_tags:
|
||||||
:return: tag_key_value_pairs_to_set: a dict of key value pairs that need to be set in AWS. If all tags are identical this dict will be empty
|
:return: tag_key_value_pairs_to_set: a dict of key value pairs that need to be set in AWS. If all tags are identical this dict will be empty
|
||||||
:return: tag_keys_to_unset: a list of key names that need to be unset in AWS. If no tags need to be unset this list will be empty
|
:return: tag_keys_to_unset: a list of key names (type str) that need to be unset in AWS. If no tags need to be unset this list will be empty
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tag_key_value_pairs_to_set = {}
|
tag_key_value_pairs_to_set = {}
|
||||||
|
|
|
@ -314,4 +314,6 @@ to modify and a list of tag key names that you need to remove. Purge is True by
|
||||||
existing tags will not be modified.
|
existing tags will not be modified.
|
||||||
|
|
||||||
This function is useful when using boto3 'add_tags' and 'remove_tags' functions. Be sure to use the other helper function
|
This function is useful when using boto3 'add_tags' and 'remove_tags' functions. Be sure to use the other helper function
|
||||||
'boto3_tag_list_to_ansible_dict' to get an appropriate tag dict before calling this function.
|
'boto3_tag_list_to_ansible_dict' to get an appropriate tag dict before calling this function. Since the AWS APIs are not
|
||||||
|
uniform (e.g. EC2 versus Lambda) this will work without modification for some (Lambda) and others may need modification
|
||||||
|
before using these values (such as EC2, with requires the tags to unset to be in the form [{'Key': key1}, {'Key': key2}]).
|
||||||
|
|
Loading…
Reference in a new issue