Skip to content

Call CloudFormation CreateStack from template stored as Systems Manager Document

0

According to the documentation for the CloudFormation CreateStack operation, for the TemplateURL parameter, you can pass in an S3 URL. This is the traditionally supported mechanism for larger template files.

However, it also supports passing in a stored Systems Manager document (of type CloudFormation).

The URL of a file containing the template body. The URL must point to a template (max size: 1 MB) that's located in an Amazon S3 bucket or a Systems Manager document. The location for an Amazon S3 bucket must start with https://.

Since July 8th, 2021, AWS Systems Manager Application Manager supports storing, versioning, and deploying CloudFormation templates.

https://aws.amazon.com/about-aws/whats-new/2021/07/aws-systems-manager-application-manager-now-supports-full-lifecycle-management-of-aws-cloudformation-templates-and-stacks/

The documentation doesn't indicate the correct URL to use for a CloudFormation template that's stored in the Application Manager service.

💡 Question: How do you call the CloudFormation CreateStack operation and specify a Systems Manager document (of type CloudFormation) as the template to deploy?

Do you need to specify the document ARN or something? The documentation is unclear on this.

asked 2 years ago259 views

2 Answers
1
Accepted Answer

Hello.

The following document contains an example of command execution that specifies an SSM document.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/service_code_examples.html#create-stack-sdk

The following create-stack command creates a stack with the name myteststack using an AWS Systems Manager document for the template URL.

aws cloudformation create-stack --stack-name myteststack \
     --template-url "ssm-doc://arn:aws:ssm:us-east-1:123456789012:document/documentName"
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

To call the CloudFormation CreateStack operation using a Systems Manager document (of type CloudFormation) as the template, you can use the Systems Manager document ARN in the TemplateURL parameter. The format for specifying a Systems Manager document as the template URL is:

"ssm-doc://arn:aws:ssm:region:account-id:document/documentName"

Here's an example of how you would use this in an AWS CLI command:

aws cloudformation create-stack --stack-name myteststack --template-url "ssm-doc://arn:aws:ssm:us-east-1:123456789012:document/documentName"

This format allows CloudFormation to retrieve the template content from the specified Systems Manager document. Make sure that the document you're referencing is of type CloudFormation template and that you have the necessary permissions to access it.

When using this method, you don't need to upload your template to an S3 bucket first, which can simplify your workflow, especially if you're already managing your CloudFormation templates as Systems Manager documents.

Remember that the Systems Manager document containing your CloudFormation template must be in the same AWS region where you're creating the stack. Also, ensure that your IAM permissions allow both access to the Systems Manager document and the ability to create CloudFormation stacks.
Sources
Examples of CloudFormation stack operation commands for the AWS CLI and PowerShell - AWS CloudFormation
AWS Systems Manager Documents - AWS Systems Manager
CreateStack - AWS CloudFormation

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.