antonbabenko / modules.tf-lambda

Infrastructure as code generator - from visual diagrams created with Cloudcraft.co to Terraform
https://www.cloudcraft.co/
MIT License
351 stars 56 forks source link

Implement validation flow before rendering #18

Open antonbabenko opened 5 years ago

antonbabenko commented 5 years ago

Validation flow:

Examples of JSON responses from modules.tf /validate endpoint:

When there are errors:

{
"comments": [
  {"severity": "INFO", "text": "Network load-balancer does not have Terraform module yet, and it will not be exported"},
  {"severity": "ERROR", "text": "VPC 'vpcname' can't span across multiple regions (eu-west-1, eu-west-2, us-east-1). VPC can be only in one region."},
  {"severity": "ERROR", "text": "VPC 'vpcname' and resources it contains should be in the same region."}
],
"summary": "Please correct blueprint and try again",
"valid": false
}

When success:

{
"comments": [
  {"severity": "INFO", "text": "Network load-balancer does not have Terraform module yet, and it will not be exported"},
],
"summary": "Validation passed",
"valid": true
}

Description:

  1. If there is at least one hard-failure valid is set to false. This means the user can't see the "Continue" button and get zip-archive.
  2. summary - is a human-friendly text to show.
  3. comments - is a list of severity and text.