I have the following python boto3 code. It works fine to get me all the AutoScalingGroup names with a tag of "SubEnvironment" that has a value of "teal"
What I really want is to add "StackName" with a value of "foo" to this so that I get exactly the results I want. I'm unfamiliar with JMESPath so I'm not sure how to do this.
def get_autoscale_groups():
asg_name_list =[]
while True:
paginator = client.get_paginator('describe_auto_scaling_groups')
page_iterator = paginator.paginate(
PaginationConfig={'PageSize': 100}
)
for page in page_iterator:
filtered_asgs = page_iterator.search(
'AutoScalingGroups[] | [?contains(Tags[?Key==`{}`].Value, `{}`)]'.format(
'SubEnvironment', 'teal')
#Want to add 'StackName', 'foo' somehow
)
for asg in filtered_asgs:
asg_name_list.append(asg['AutoScalingGroupName'])
try:
marker = page['Marker']
print(marker)
except KeyError:
break
#print(asg_name_list)
return asg_name_list