aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.5k stars 3.85k forks source link

(cli): Could not create a change set ... Template format error: At least one Resources member must be defined #29233

Closed andreialecu closed 19 hours ago

andreialecu commented 6 months ago

Describe the bug

I have a couple of stacks where the change set mechanism doesn't seem to work.

Expected Behavior

No changes should be observed in this stack. Also, the changeset should work.

Current Behavior

It hints at running the command with -v, and there I can see the following logged:

[14:08:59] Call failed: createChangeSet({"StackName":"...","ChangeSetName":"cdk-diff-change-set","ChangeSetType":"CREATE","Description":"CDK Changeset for diff 8ed8623f-893f-4955-8cff-38c32722e917","ClientToken":"diff8ed8623f-893f-4955-8cff-38c32722e917","TemplateBody":"Parameters:\n  BootstrapVersion:\n    Type: AWS::SSM::Parameter::Value<String>\n    Default: /cdk-bootstrap/hnb659fds/version\n    Description: Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]\nRules:\n  CheckBootstrapVersion:\n    Assertions:\n      - Assert:\n          Fn::Not:\n            - Fn::Contains:\n                - - \"1\"\n                  - \"2\"\n                  - \"3\"\n                  - \"4\"\n                  - \"5\"\n                - Ref: BootstrapVersion\n        AssertDescription: CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.\n","Parameters":[],"RoleARN":"arn:aws:iam::...:role/cdk-hnb659fds-cfn-exec-role-...-eu-west-1","Capabilities":["CAPABILITY_IAM","CAPABILITY_NAMED_IAM","CAPABILITY_AUTO_EXPAND"]}) => Template format error: At least one Resources member must be defined. (code=ValidationError)
[14:08:59] Template format error: At least one Resources member must be defined.

The "template differences" fallback shows:

Could not create a change set, will base the diff on template differences (run again with -v to see the reason)
Parameters
[+] Parameter BootstrapVersion BootstrapVersion: {"Type":"AWS::SSM::Parameter::Value<String>","Default":"/cdk-bootstrap/hnb659fds/version","Description":"Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"}

Other Changes
[+] Unknown Rules: {"CheckBootstrapVersion":{"Assertions":[{"Assert":{"Fn::Not":[{"Fn::Contains":[["1","2","3","4","5"],{"Ref":"BootstrapVersion"}]}]},"AssertDescription":"CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."}]}}

This also always marks the stack as having diffs, even though when it's deployed, diffs don't exist.

Reproduction Steps

No repro, but I hope the logging above is relevant to see what Resources member is not defined and why.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.130.0

Framework Version

No response

Node.js Version

18.16.1

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

spssmn-aws commented 6 months ago

Same issue for me - same setup as reporter.

comcalvi commented 19 hours ago

Reproduced on 2.130.0, verified that this does not happen on 2.158.0.

github-actions[bot] commented 19 hours ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.