-
Cloudformation scripts can become monolithic and huge, I am looking for a solution to break them up into smaller, more manageable pieces. Preprocessing them with My hope is to split a main CF file into multiple: # main.cloudformation.yaml
AWSTemplateFormatVersion: 2010-09-09
Parameters:
S3BucketName:
Type: String # s3.cloudformation.yaml
Resources:
S3BucketWebAssets:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub '${S3BucketName}' Where the expected output from my combiner: # Expected output
AWSTemplateFormatVersion: 2010-09-09
Parameters:
S3BucketName:
Type: String
Resources:
S3BucketWebAssets:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub '${S3BucketName}' I was hoping I could do something as simple as: const fs = require('node:fs')
const path = require('node:path')
const YAML = require('yaml')
const mainContants = fs.readFileSync(path.join(__dirname, 'main.cloudformation.yaml'))
const bucketContants = fs.readFileSync(path.join(__dirname, 's3.cloudformation.yaml'))
const main = YAML.parse(mainContants)
const s3 = YAML.parse(bucketContants)
const result = main
result.Resources = {
...s3.Resources
}
console.log(YAML.stringify(result)) However, Can this be achieved? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes. Use |
Beta Was this translation helpful? Give feedback.
Yes. Use
YAML.parseDocument()
, and append the second document's contents to the first.