I am trying to list the instances on tag values of different tag keys For eg> one tag key - Environment, other tag key - Role. My code is given below :
imp
This looks familiar, did I modify this for somebody somewhere ;-) . Actually the code I wrote is in rush and not tested properly (And I don't bother to amend the % string formating and replace it with str.format() ) . In fact,using Filters parameter is not properly documented in AWS.
Please refer to Russell Ballestrini blog Filtering AWS resources with Boto3 to learn more about correct boto Filters method.
[{"tag:keyname","Values": [""] }] and it doesn't work. (Actually the origin code I assume the developer know how the filters works, so I just amend the structure only). [{"Name" :"tag:keyname", "Values":[""] }]. It is tricky.So the correct way of formatting a filters if you want to use for your example
filters = [{'Name':'tag:environment', 'Values':[Env]},
{'Name':'tag:role', 'Values':[Role]}
]
(Update) And to make sure argparse take up string value, you just enforce the argument to take string values
parser.add_argument('Env', type=str, default="environment",
help='value for tag:environment');
parser.add_argument('Role', type=str,default="role",
help='value for tag:role');