mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 08:53:13 +00:00
* fix(infra): share the afterhours VPC when existing_vpc_id is set Prod is at the account VPC quota, so the v1.0.0 apply destroyed Lambda/API Gateway then failed on CreateVpc. Skip creating a sixth VPC when the workspace supplies afterhours subnets. * style(test): format the VPC terraform assertion for ruff
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Meals creates a VPC unless existing_vpc_id is set (prod shares afterhours)."""
|
|
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
TERRAFORM = ROOT / "terraform"
|
|
|
|
|
|
def _read(name: str) -> str:
|
|
return (TERRAFORM / name).read_text()
|
|
|
|
|
|
def test_meals_owns_a_vpc_instead_of_looking_up_default():
|
|
vpc = _read("vpc.tf")
|
|
ecs = _read("ecs.tf")
|
|
locals_tf = _read("locals.tf")
|
|
variables = _read("variables.tf")
|
|
data = _read("data.tf")
|
|
|
|
assert 'resource "aws_vpc" "this"' in vpc
|
|
assert "count = local.manage_vpc ? 1 : 0" in vpc
|
|
assert 'variable "existing_vpc_id"' in variables
|
|
assert 'variable "existing_public_subnet_ids"' in variables
|
|
assert 'manage_vpc = var.existing_vpc_id == ""' in locals_tf
|
|
assert 'data "aws_vpc" "default"' not in ecs
|
|
assert "data.aws_vpc.default" not in ecs
|
|
assert "data.aws_subnets.default" not in ecs
|
|
assert "vpc_id = local.vpc_id" in ecs
|
|
assert "subnets = local.public_subnet_ids" in ecs
|
|
assert "subnets = local.public_subnet_ids" in ecs
|
|
assert "ec2:CreateVpc" in _read("hcp_iam.tf")
|
|
assert 'check "existing_vpc_pair"' in data
|
|
assert 'check "existing_subnets_in_vpc"' in data
|
|
assert "from = aws_vpc.this" in vpc
|
|
assert "to = aws_vpc.this[0]" in vpc
|