Skip to content

Validation of resource factories files #2316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sruffilli opened this issue May 28, 2024 · 1 comment
Closed

Validation of resource factories files #2316

sruffilli opened this issue May 28, 2024 · 1 comment
Labels
on:tools New or changed tool

Comments

@sruffilli
Copy link
Collaborator

Resource factories are supported by many modules and heavily used in FAST, but YAML files are currently not validated, neither on documentation examples, nor on FAST tests.

Running terraform plan on modules containing such assets is not a comprehensive test, as a typo on an optional attribute wouldn't be caught by terraform, but might potentially have destructive consequences on the infrastructure, if the plan goes through without a human review.

Formal validation is the only way to catch such errors - however maintaining the schema up-to-date (e.g. subnets) is a toil, which means any manually-generated schema which is not automatically tested is prones to become obsolete.

We could:

  • Introduce schema validation on documentation, forcing PR authors to ensure that any change which includes an example is validated. This action is non comprehensive as it doesn't cover undocumented scenarios.
  • Automatically generate a validation schema based on the factory variables, and test examples/assets against the generated schema.
  • Abandon validation altogether (true as of today)
@sruffilli sruffilli added the on:tools New or changed tool label May 28, 2024
@sruffilli sruffilli reopened this May 28, 2024
@sruffilli
Copy link
Collaborator Author

  • Introduce schema validation on documentation, forcing PR authors to ensure that any change which includes an example is validated. This action is non comprehensive as it doesn't cover undocumented scenarios.

We've ruled this out

  • Automatically generate a validation schema based on the factory variables, and test examples/assets against the generated schema.

There's no easy way to do this - any approach has to go through recursively parsing object types (which the hcl2 python parser doesn't do), which is quite complex and outweights the benefits.

  • Abandon validation altogether (true as of today)

I'm afraid this is it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on:tools New or changed tool
Projects
None yet
Development

No branches or pull requests

1 participant