Hi all,
boto3 returns tags of a resource as a list of dicts. Each dict has a key named ‘Key’ and a key named ‘Value’.
E.g.
‘Tags’: [
{
‘Key’: ‘mykey’,
‘Value’: ‘myvalue’
},
]
Across all Ansible modules (that i know of), we represent aws tags as just a straight dict of key:value pairs.
E.g.
‘Tags’: {
‘mykey’: ‘myvalue’
},
Can i confirm with all that we are happy to keep doing it this way? I think it is the best way because it allows you to use a statement later in your play such as when: ec2.tags[‘mykey’] == ‘myvalue’ as opposed to having to combine that with a with_items loop to look through the whole list of tags.
If yes, i’ll add a small helper function in module_utils to convert the boto3 tag lists to ansible tag dicts.
I’m also going to make a similar small PR for the reverse. boto3 wants filter specified as a list of dicts contained ‘Name’ and ‘Value’ keys. However, ansible usually just required a dict of Name:Value pairs. I’ll write a helper function to convert the dict to a boto3 acceptable filter list.