|
| 1 | +# Cloud WAN VPC attachment options: routing_policy_label, dns_support, |
| 2 | +# security_group_referencing (ported from v4.9.0). Defaults must be null so the |
| 3 | +# AWS service defaults apply and existing attachments see no diff. |
| 4 | + |
| 5 | +mock_provider "aws" { |
| 6 | + override_during = plan |
| 7 | + |
| 8 | + mock_data "aws_partition" { defaults = { partition = "aws" } } |
| 9 | + mock_data "aws_region" { defaults = { region = "us-east-1" } } |
| 10 | + mock_data "aws_caller_identity" { defaults = { account_id = "123456789012" } } |
| 11 | + |
| 12 | + mock_resource "aws_vpc" { |
| 13 | + defaults = { |
| 14 | + id = "vpc-mock" |
| 15 | + arn = "arn:aws:ec2:us-east-1:123456789012:vpc/vpc-mock" |
| 16 | + cidr_block = "10.99.0.0/16" |
| 17 | + } |
| 18 | + } |
| 19 | + mock_resource "aws_subnet" { |
| 20 | + defaults = { |
| 21 | + id = "subnet-mock" |
| 22 | + arn = "arn:aws:ec2:us-east-1:123456789012:subnet/subnet-mock" |
| 23 | + } |
| 24 | + } |
| 25 | + mock_resource "aws_networkmanager_vpc_attachment" { |
| 26 | + defaults = { id = "attachment-created" } |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +run "options_propagate_to_attachment" { |
| 31 | + command = plan |
| 32 | + variables { |
| 33 | + vpc = { name = "cwan-options-set" } |
| 34 | + addressing = { primary = { cidr_block = "10.99.0.0/16" } } |
| 35 | + availability_zones = { names = ["us-east-1a"] } |
| 36 | + subnets = { |
| 37 | + cwan = { |
| 38 | + role = "core_network" |
| 39 | + ipv4 = { cidrs_by_az = { us-east-1a = "10.99.0.0/28" } } |
| 40 | + core_network_options = { |
| 41 | + id = "cnet-0123456789abcdef0" |
| 42 | + routing_policy_label = "prod-attachments" |
| 43 | + dns_support = true |
| 44 | + security_group_referencing = false |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + assert { |
| 51 | + condition = aws_networkmanager_vpc_attachment.this["vpc"].routing_policy_label == "prod-attachments" |
| 52 | + error_message = "routing_policy_label was not propagated to the Cloud WAN VPC attachment" |
| 53 | + } |
| 54 | + |
| 55 | + assert { |
| 56 | + condition = [for o in aws_networkmanager_vpc_attachment.this["vpc"].options : o.dns_support][0] == true |
| 57 | + error_message = "dns_support was not propagated to the Cloud WAN VPC attachment options" |
| 58 | + } |
| 59 | + |
| 60 | + assert { |
| 61 | + condition = [for o in aws_networkmanager_vpc_attachment.this["vpc"].options : o.security_group_referencing_support][0] == false |
| 62 | + error_message = "security_group_referencing was not propagated to the Cloud WAN VPC attachment options" |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +run "options_default_to_null" { |
| 67 | + command = plan |
| 68 | + variables { |
| 69 | + vpc = { name = "cwan-options-default" } |
| 70 | + addressing = { primary = { cidr_block = "10.99.0.0/16" } } |
| 71 | + availability_zones = { names = ["us-east-1a"] } |
| 72 | + subnets = { |
| 73 | + cwan = { |
| 74 | + role = "core_network" |
| 75 | + ipv4 = { cidrs_by_az = { us-east-1a = "10.99.0.0/28" } } |
| 76 | + core_network_options = { |
| 77 | + id = "cnet-0123456789abcdef0" |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + assert { |
| 84 | + condition = aws_networkmanager_vpc_attachment.this["vpc"].routing_policy_label == null |
| 85 | + error_message = "routing_policy_label must default to null (AWS default preserved)" |
| 86 | + } |
| 87 | +} |
0 commit comments