Reputation: 21824
I am trying to load a serverless file using a yaml library to do some preprocessing:
const yaml = require('js-yaml');
const file = await fs.readFile(path, { encoding: 'utf8' });
const doc = yaml.load(file);
I am getting an error:
YAMLException: unknown tag !<!Ref> (26:42)
Because of this line:
S3_BUCKET: !Ref ComposerBucket
Is it possible to load serverless files into an object somehow? I'm thinking maybe serverless is using some particular schema that I need to define when loading, but I don't know.
const doc = yaml.load(file, { schema: 'serverless-framework' });
Do you have any idea how I can get this to work?
Upvotes: 1
Views: 176
Reputation: 21824
I found the solution while browsing the serverless npm package source code:
const cloudformationSchema = require('@serverless/utils/cloudformation-schema');
const doc = yaml.load(file, { schema: cloudformationSchema });
Upvotes: 2