Registry / devops / cloudformation-js-yaml-schema

cloudformation-js-yaml-schema

JSON →
library0.4.2jsnpmunverified

Provides a custom js-yaml schema that allows parsing and dumping CloudFormation YAML files while ignoring or handling CloudFormation-specific local tags like !Ref, !Base64, !GetAtt, etc. Current stable version 0.4.2. Useful for linting, validation, and transformation of CloudFormation templates in JavaScript. Differentiates from general YAML parsers by preserving CFN intrinsic functions without throwing parse errors. Release cadence is low (last update May 2021).

npm install cloudformation-js-yaml-schema
INSTALL
IMPORT
SIG · CLOUDFORMATION-JS-
C
cloudformation-js-yaml-schema
devopsjavascriptv0.4.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cloudformationSchema
import { cloudformationSchema } from 'cloudformation-js-yaml-schema'
const { cloudformationSchema } = require('cloudformation-js-yaml-schema')
ESM default; works with both ESM and CJS environments
ignoreTags
import { ignoreTags } from 'cloudformation-js-yaml-schema'
import ignoreTags from 'cloudformation-js-yaml-schema'
Named export; do not use default import
tags
import { tags } from 'cloudformation-js-yaml-schema'
Exports a list of supported tag names (e.g., !Ref, !GetAtt)

Parses CloudFormation YAML with CFN tags using custom schema.

import { cloudformationSchema } from 'cloudformation-js-yaml-schema'; import yaml from 'js-yaml'; const cfnYaml = ` Resources: MyBucket: Type: 'AWS::S3::Bucket' Properties: BucketName: !Ref BucketNameParam `; const doc = yaml.load(cfnYaml, { schema: cloudformationSchema }); console.log(doc); // Output: { Resources: { MyBucket: { Type: 'AWS::S3::Bucket', Properties: { BucketName: { '!Ref': 'BucketNameParam' } } } } }
Debug
Known issues
gotchaCustom tags are represented as objects with key '!TagName', not as native YAML tag.
fix
Access tags via obj['!Ref'] or similar, not as plain strings.
affects: >=0.1.0
gotchaUsing with js-yaml's default or other schemas may cause parse errors for CFN tags.
fix
Always pass { schema: cloudformationSchema } to yaml.load/dump when working with CloudFormation templates.
affects: >=0.1.0
deprecatedThe tags.json file is no longer the authoritative source; use the exported ``tags`` array.
fix
Import { tags } from 'cloudformation-js-yaml-schema' instead of reading tags.json.
affects: >=0.4.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'toString')
Using js-yaml's default schema without the CloudFormation schema.
fix
Set schema: cloudformationSchema in yaml.load options.
Unknown tag: !Ref
js-yaml doesn't recognize CloudFormation tags by default.
fix
Use the cloudformationSchema as shown in quickstart.
Cannot find module 'js-yaml'
js-yaml is a peer dependency not installed automatically.
fix
Run npm install js-yaml.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
js-yamlrequiredPeer dependency; required to define custom schema
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources