Unable to use --cli-input-yaml with aws cloudformation create-stack #8866
-
|
Hello, I am trying to wrap up arguments for the command My current working command line is: aws cloudformation create-stack --stack-name CfnGitSyncPrerequisites --template-body file://git-sync/prerequisites.yaml --capabilities CAPABILITY_NAMED_IAMHence reproducing the exact same arguments in a YAML file ( StackName: CfnGitSyncPrerequisites
TemplateBody: file://git-sync/prerequisites.yaml
Capabilities:
- CAPABILITY_NAMED_IAMBut when using this YAML file with ❯ aws cloudformation create-stack --cli-input-yaml file://git-sync-prerequisites-stack.yaml
An error occurred (ValidationError) when calling the CreateStack operation: Template format error: unsupported structure.I have tried to compare the Any idea on how to debug this or make this work is welcome. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
So CloudFormation ends up receiving Template format error: unsupported structure. The two correct ways to make this work are: Use aws cloudformation create-stack Or, don’t use TemplateBody in the input file at all and use TemplateURL instead (upload the template to S3 and reference it): StackName: CfnGitSyncPrerequisites
If you want to debug what is actually being sent, run with Summary: keep the template file reference on the command line (recommended), or use TemplateURL; embedding |
Beta Was this translation helpful? Give feedback.
--cli-input-yamlreads an API request structure from your YAML file, but it does not reliably expandfile://...references inside that YAML into the file contents forTemplateBody.So CloudFormation ends up receiving
TemplateBodyas the literal stringfile://git-sync/prerequisites.yaml(not the template), and then fails template parsing with:Template format error: unsupported structure.
The two correct ways to make this work are:
Use
--cli-input-yamlfor everything EXCEPT the template body, and pass the template on the command line (CLI args override the input file):aws cloudformation create-stack
--cli-input-yaml file://git-sync-prerequisites-stack.yaml
--template-body file://git-syn…