'Is it possible to statically specify AWS::StackName inside a cloudformation template?
Is it possible to statically specify AWS::StackName inside a cloudformation template? Or can this only be specified as a parameter when you run the template?
As far as I understand, this value can only be read via pseudo parameters, not set:
Solution 1:[1]
No, you can't.
Template is just a content of your stack, it doesn't set it's metainfo (like name, deployment region etc.).
Note, that you can use same template for multiple stacks, or even sub-stacks.
Solution 2:[2]
A less than ideal but usable workaround if your goal is just to standardize stack name on manual AWS Console deployments can be to add a "fake" Parameter that a user can copy and paste.
...
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Stack Name Config"
Parameters:
- StacknameToCopy
ParameterLabels:
StacknameToCopy:
default: Stack Name to Copy
Parameters:
StacknameToCopy:
Type: String
Description: Copy and paste this stack name above when deploying
Default: SPECIFIC-naming-convention-123
Programmatic option would require using a framework like serverless.com or an AWS SDK/CLI wrapper.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rafa? Wrzeszcz |
Solution 2 | Warren Kim |