Open chrisrtaylor opened 6 months ago
This is a little bit tricky but I was able to synthesize with this:
const content = yaml.parse(fs.readFileSync(path.join(__dirname, './demo.yaml')).toString());
new ssm.CfnDocument(this, "TestSsmDoc", {
content,
name: "TestSsmDocument",
documentType: "Command",
documentFormat: "YAML",
});
And I got this
TestSsmDoc:
Type: AWS::SSM::Document
Properties:
Content:
schemaVersion: "2.2"
description: Test SSM doc for CDK.
mainSteps:
- action: aws:runShellScript
name: test
inputs:
runCommand: |
echo "Hello, World!"
DocumentFormat: YAML
DocumentType: Command
Name: TestSsmDocument
Let me know if it works for you.
Yes, wrapping the string content with the yaml library does work and is an okay work around. However, the documentation linked above indicates that the content
property does accept the String type which is still a problem.
Describe the bug
According to the documentation for the content property of CfnDocument, it should be able to take an object representing JSON formatted content or a String if creating a YAML based document. When trying to use a string value for content, the document fails to create
Expected Behavior
I should be able to define a document using a YAML formatted string as content. The following code should synthesize and create the appropriate resource:
Current Behavior
The above code fails to synthesize with the following error:
If I wrap the string literal in
new String(...)
, the stack synthesizes, but does so incorrectly. It renders the context as an indexed dictionary of the string array which fails to create the resource with the errorResource handler returned message: "Invalid request provided: Missing "schemaVersion" in the document.
:Reproduction Steps
Create a stack with the following stack and attempt to synthesize the stack:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.114.1 (build 02bbb1d)
Framework Version
No response
Node.js Version
v18.16.1
OS
Mac OS X
Language
TypeScript
Language Version
Typescript (5.2.2)
Other information
No response