Skip to content

Instantly share code, notes, and snippets.

@olsaki
olsaki / get_cfn_resources_by_stack_with_param.py
Created August 17, 2016 12:00
Get CloudFormation resources mapping from a stack with a specific parameter
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'] }

Keybase proof

I hereby claim:

  • I am olsaki on github.
  • I am olsaki (https://keybase.io/olsaki) on keybase.
  • I have a public key ASBfCJ5sEGUuTnezeYR8AyphVpTh7NsP0oDda9qsXT6BYgo

To claim this, I am signing this object: