-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AWS::CloudFormation::Stackset resource to the cloudformation package command #5590
Comments
AWS::CloudFormation::Stackset
resource to the cloudformation package
command
It would be great to see this included. In the meantime you can use cfn-flip and jq to preprocess and postprocess the result for the package command. cfn-flip template.yaml \
| jq '
.Resources |= with_entries(
(.value.Type == "AWS::CloudFormation::StackSet") as $is_stackset
| .key |= (if $is_stackset then "__STACKSET__" + . else . end)
| .value.Type |= (if $is_stackset then "AWS::CloudFormation::Stack" else . end)
)' \
| cfn-flip > preprocessed.yaml
aws cloudformation package \
--template-file preprocessed.yaml \
--s3-bucket ... \
--output-template-file packaged.yaml
cfn-flip packaged.yaml \
| jq '
.Resources |= with_entries(
(.key | startswith("__STACKSET__")) as $is_stackset
| .key |= (if $is_stackset then split("__STACKSET__")[1] else . end)
| .value.Type |= (if $is_stackset then "AWS::CloudFormation::StackSet" else . end)
)' \
| cfn-flip > postprocessed.yaml cfn-flip converts YAML CloudFormation templates to JSON and vice versa. The first jq program modifies each stack set resource so that the package command will process them. It replaces the StackSet type declaration with a Stack type declaration. It prepends a __STACKSET__ flag to the logical resource name so that the process can be reversed. The preprocessed.yaml is an invalid CloudFormation template because the StackSet properties don't make sense for the Stack type. The package command ignores this and does its job. The packaged.yaml is still an invalid CloudFormation template, but it contains the S3 URLs we were hoping for. The second jq program reverses the changes of the first program. The postprocessed.yaml is once more a valid CloudFormation template and more or less the result you would hope for. Comments in the original template.yaml are lost, but the resource graph is equivalent. All the files are written to the same directory as the template.yaml to ensure that relative paths are still correct. After deploying the template you will probably want to delete preprocessed.yaml, packaged.yaml, and postprocessed.yaml to keep your source files clean. |
Any chance this is going to get added soon? |
Thanks for the PR - I made it work with your dev branch. Hope this gets merged soon! |
Another workaround is to use CloudFormation Rain CLI. Its The Resources:
Example:
Type: AWS::CloudFormation::StackSet
Properties:
StackSetName: example
TemplateURL: !Rain::S3Http instance-template.yaml |
Any change to merge the pull request #5591? SAM CLI does not support packaging stacksets as suggested in some of the comments here/in the PR, and Rain CLI does not look like something I would like to adopt at the moment. One alternative approach to the suggested script I can think of is to package the file the AWS::CloudFormation::Stackset's TemplateURL property points to, upload it to S3 and change the local path to the upload's URL. |
Hi. I hope this feature will come soon. One real workaround is this:
By this solution you need to know, that the executions of functions in the |
Is your feature request related to a problem? Please describe.
I would like to be able to use the
aws cloudformation package
command to package theAWS::CloudFormation::Stackset
resourceTemplateURL
property. Currently it is not supported.Describe the solution you'd like
See above
Describe alternatives you've considered
N/A
Additional context
I have started a PR for this - #5591
The text was updated successfully, but these errors were encountered: