cfn-include
cfn-include copied to clipboard
Can't get YAML template working.
If this repo is still active, I can't seem to get this working with YAML template and YAML include file. Is cfn-include supposed to work with YAML inputs in addition to JSON inputs just like CloudFormation does?
If so, equivalent YAML examples for local file and S3 sourced include files would be greatly appreciated.
If not, any plans to support YAML?
Thx!
Minimal example YAML template and YAML include file attached. .txt file suffixes added only to allow attaching to the GitHub issue. minimal-include-frag.yaml.txt minimal-frag.yaml.txt
YAML is definitely supported. Mixing tags and plain objects is not supported. Try this instead:
Resources:
group:
Type: AWS::IAM::Group
Properties:
GroupName: testing-delete-me
- !Include {type: json, location: /mnt/c/Users/foo/Documents/GitHub/cloudformation/include/minimal-frag.yaml.txt}
+ Fn::Include: {type: json, location: /mnt/c/Users/foo/Documents/GitHub/cloudformation/include/minimal-frag.yaml.txt}
Thx!
When I do that this is the error I get:
$ cfn-include minimal-include-frag.yaml --yaml > output.template
(node:7020) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy
SyntaxError: YAMLException: can not read an implicit mapping pair; a colon is missed at line 7, column 129:
... n/include/minimal-frag.yaml.txt}
^,SyntaxError: Unexpected token R in JSON at position 0
Note the column numbers are slightly different due to redacted parts of the include file path, bit it points to the end of the last line that ends with "}".
Also, please note the JavaScript v2 version warning.
It works fine for me. Maybe try quoting the filename:
echo 'Resources:
group:
Type: AWS::IAM::Group
Properties:
GroupName: testing-delete-me
Fn::Include: {type: json, location: "test.yml"}
' | npx cfn-include
{
"Resources": {
"group": {
"Type": "AWS::IAM::Group",
"Properties": {
"GroupName": "testing-delete-me"
}
}
}
}