aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

validate-template fails to identify AWS::CloudFormation::Stack Properties TemplateBody as invalid #740

Open sparr opened 6 months ago

sparr commented 6 months ago

Describe the bug

The following template validates successfully, but then fails during create-stack due to Encountered unsupported property TemplateBody. Other more-obviously-invalid property names like foo produce expected validation failures.

Expected Behavior

Validation failure

Current Behavior

Successful validation

Reproduction Steps

aws cloudformation validate-template --template-body file://thefollowingfile.yaml

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  TestStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateBody:
        AWSTemplateFormatVersion: '2010-09-09'

Possible Solution

No response

Additional Information/Context

No response

CLI version used

aws-cli/2.14.4

Environment details (OS name and version, etc.)

Python/3.11.6 Darwin/23.1.0 MacOS/14.1

max-allan-surevine commented 5 months ago

I think this is more about missing functionality than the Linter being wrong.

TemplateBody is a documented parameter: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html#cfn-cloudformation-stack-templatebody

Do we need to raise a feature request to get a documented feature to work??? I just wasted a couple of hours trying to make this work, assuming I'd got something else wrong. "It must be right, it's in the docs. Maybe I've got my !Sub wrong or something..."

sparr commented 5 months ago

There's further context in https://github.com/aws-cloudformation/cfn-lint/issues/2975

Apparently TemplateBody is only valid in... some unknown context, and it's not valid when using CFN to define a Stack.

SlazyHW commented 5 months ago

Got the same issue. I want to deploy a cloudformation template using the CLI which creates two sub-stacks. I want to pass the template bodies to both stacks as variables (I extract the .yaml-files' content and convert it into .json-syntax) but I get the following error:

"Encountered unsupported property TemplateBody"

Just wasted some hours on trying to get this right. Now I have to change to S3 buckets using the TemplateURL property. Kind of annoying because its clearly part of the documentation.

max-allan-surevine commented 5 months ago

If it's only valid in some undocumented context : Then the issue is with the documentation.

If the documentation does not declare the unknown context then how can the tooling/users know what the context they must use is?

Considering Cfn is an AWS product, it has far too many bugs like this.

tim-finnigan commented 1 month ago

Thanks for reporting this issue and your patience here. Based on what has been discussed, this does appear to be an issue with the underlying ValidateTemplate API and/or documentation. Since service APIs like that are used across SDKs, I'll go ahead and transfer this to our cross-SDK repository. I'll also reach out to the CloudFormation team regarding this issue and will share any updates here. Thanks again. (ref: P129370565)