Get template of CloudFormation stack

Get template of CloudFormation stack

5

Votes

import boto3
import json
import sys

session = boto3.Session(profile_name='PROFILE_NAME')
client = session.client('cloudformation')

def GetTemplate(stackName):
    response = client.get_template(
        StackName=stackName
    )
    response = json.dumps(response)
    response = json.loads(response)
    print(type(response))
    try:
        template_body = (response['TemplateBody'])
        return (template_body)

    except KeyError:
        return ("Template is not found.")


if __name__ == '__main__':
    GetTemplate(*sys.argv[1:])

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png