Created
August 17, 2016 12:00
-
-
Save olsaki/53ced7fff4afb4e75183fc35b372366f to your computer and use it in GitHub Desktop.
Get CloudFormation resources mapping from a stack with a specific parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
{ resource['LogicalResourceId']: resource['PhysicalResourceId'] for resource in boto3.client('cloudformation').describe_stack_resources(StackName=[ s[0] for s in [ (stack['StackName'], { parameter['ParameterKey']: parameter['ParameterValue'] for parameter in stack['Parameters'] } ) for stack in boto3.client('cloudformation').describe_stacks()['Stacks'] ] if 'MyParam' in s[1] and s[1]['MyParam'] == 'MyValue' ][0])['StackResources'] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment