14

There is a serverless.yaml file which contains line like that:

VpcId: !Ref MyVpc

Yaml files are validated by check-yaml git hook which invoked by pre-commit command. So the pre-commit run --all-files run is failed with error:

could not determine a constructor for the tag '!Ref'
  in "serverless.yml", line 172, column 29

Is there a way to configure check-yaml to skip this error?

Cherry
  • 31,309
  • 66
  • 224
  • 364

2 Answers2

16
hooks:
- id: check-yaml
  args: ['--unsafe']

should do the trick. It just checks syntax instead of attempting to load the YAML.

flyx
  • 35,506
  • 7
  • 89
  • 126
  • 1
    This works, however, `Using this option removes all guarantees of portability to other yaml implementations`. – atoMerz Jul 21 '20 at 07:19
1

In your specific example above, which suggests a CloudFormation template, you can also consider cfn-python-lint's pre-commit hook.

Danielle Madeley
  • 2,616
  • 1
  • 19
  • 26