antonbabenko/modules.tf-lambda

Implement validation flow before rendering

antonbabenko opened this issue · 0 comments

Validation flow:

  • Once a user clicks “Export as Terraform code”, POST to endpoint “/validate” and JSON (with comments, severity, and recommendations) is returned.
  • Show scrollable text block with actual comments and recommendations in modal
  • Add two buttons to modal - “Edit” and “Download archive”
  • Start with single "error" to try out UI

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.