Created
May 4, 2016 17:33
-
-
Save ankona/e64e5508258cd31d2644ff9084ca5fcb to your computer and use it in GitHub Desktop.
query a cloudformation stack for it's resources and find the first RestAPI id in it
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
.. module:: get_api_id_from_stack | |
:synopsis: | |
""" | |
import boto3 | |
import sys | |
try: | |
stack_name = sys.argv[1] | |
cloudformation = boto3.client('cloudformation') | |
resp = cloudformation.describe_stack_resources(StackName=stack_name) | |
for r in resp['StackResources']: | |
if r['ResourceType'] == "AWS::ApiGateway::RestApi": | |
print r['PhysicalResourceId'] | |
break | |
except: | |
print 'missing api name' | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment