|
| 1 | +# Smoke tests for the public `quilt` module, run against the wrapper root in |
| 2 | +# this directory (see main.tf). |
| 3 | +# |
| 4 | +# Plan-only with the AWS provider mocked: no credentials, no infrastructure. |
| 5 | +# Exercises the full wiring (vpc + db + search + the CloudFormation stack), so |
| 6 | +# a change that breaks the public boundary or the vpc pass-through fails in CI. |
| 7 | +# |
| 8 | +# Assertions reference known inputs (the stack name), not mocked computed |
| 9 | +# attributes, whose generated values are intentionally arbitrary. |
| 10 | + |
| 11 | +mock_provider "aws" { |
| 12 | + # slice(..., 0, 2) and the cidrsubnet math in the vpc submodule need at |
| 13 | + # least two AZ names; mocked collections are otherwise empty. |
| 14 | + mock_data "aws_availability_zones" { |
| 15 | + defaults = { |
| 16 | + names = ["us-east-1a", "us-east-1b", "us-east-1c"] |
| 17 | + } |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +run "new_vpc_plans" { |
| 22 | + command = plan |
| 23 | + variables { |
| 24 | + create_new_vpc = true |
| 25 | + internal = false |
| 26 | + } |
| 27 | + assert { |
| 28 | + condition = output.stack_name == "quilt-test" |
| 29 | + error_message = "The CloudFormation stack must be named after var.name" |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +run "new_vpc_internal_plans" { |
| 34 | + command = plan |
| 35 | + variables { |
| 36 | + create_new_vpc = true |
| 37 | + internal = true |
| 38 | + } |
| 39 | + # internal = true exercises the most conditional wiring in quilt/main.tf: |
| 40 | + # the PublicSubnets/UserSubnets null-coalescing and the internal-gated api |
| 41 | + # endpoint. |
| 42 | + assert { |
| 43 | + condition = output.stack_name == "quilt-test" |
| 44 | + error_message = "The CloudFormation stack must be named after var.name" |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +run "existing_vpc_plans" { |
| 49 | + command = plan |
| 50 | + variables { |
| 51 | + create_new_vpc = false |
| 52 | + internal = false |
| 53 | + vpc_id = "vpc-00000000000000000" |
| 54 | + intra_subnets = ["subnet-intra-a", "subnet-intra-b"] |
| 55 | + private_subnets = ["subnet-priv-a", "subnet-priv-b"] |
| 56 | + public_subnets = ["subnet-pub-a", "subnet-pub-b"] |
| 57 | + user_security_group = "sg-00000000000000000" |
| 58 | + } |
| 59 | + assert { |
| 60 | + condition = output.stack_name == "quilt-test" |
| 61 | + error_message = "The CloudFormation stack must be named after var.name" |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +run "existing_vpc_internal_plans" { |
| 66 | + command = plan |
| 67 | + variables { |
| 68 | + create_new_vpc = false |
| 69 | + internal = true |
| 70 | + vpc_id = "vpc-00000000000000000" |
| 71 | + api_endpoint = "vpce-00000000000000000" |
| 72 | + intra_subnets = ["subnet-intra-a", "subnet-intra-b"] |
| 73 | + private_subnets = ["subnet-priv-a", "subnet-priv-b"] |
| 74 | + public_subnets = null |
| 75 | + user_security_group = "sg-00000000000000000" |
| 76 | + user_subnets = ["subnet-user-a", "subnet-user-b"] |
| 77 | + } |
| 78 | + # internal = true on the existing-VPC path exercises quilt's pass-through of |
| 79 | + # api_endpoint + user_subnets and the internal-gated CFN wiring. |
| 80 | + assert { |
| 81 | + condition = output.stack_name == "quilt-test" |
| 82 | + error_message = "The CloudFormation stack must be named after var.name" |
| 83 | + } |
| 84 | +} |
0 commit comments