Skip to content

Commit 3dcf7b5

Browse files
Cristobalpablo19sc
andcommitted
feat: Cloud WAN VPC attachment options (parity with v4.9.0)
Adds routing_policy_label, dns_support and security_group_referencing to core_network_options, wired to aws_networkmanager_vpc_attachment. Defaults are null so the AWS service defaults apply and existing attachments see no diff on upgrade. Ports the remaining v4.9.0 scope (PR aws-ia#187) to v5; enable_dns64 and the NAT64 route were already present. Co-authored-by: Pablo Sanchez Carmona <pablo19sc@users.noreply.github.com>
1 parent 181e084 commit 3dcf7b5

4 files changed

Lines changed: 98 additions & 0 deletions

File tree

attachments.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,14 @@ resource "aws_networkmanager_vpc_attachment" "this" {
229229
for az in local.azs : local.subnet_arns["${each.value.group}/${az}"]
230230
]
231231

232+
routing_policy_label = each.value.options.routing_policy_label
233+
232234
options {
233235
appliance_mode_support = each.value.options.appliance_mode
234236
ipv6_support = each.value.ipv6
237+
# null defers to the AWS service defaults so existing attachments see no diff
238+
dns_support = each.value.options.dns_support
239+
security_group_referencing_support = each.value.options.security_group_referencing
235240
}
236241

237242
tags = merge(var.tags, each.value.tags, {

docs/attachments.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ subnets = {
7171

7272
Create mode owns the Network Manager VPC attachment; inject mode uses `create = false` plus `attachment_id`. `core_network` and `core_network_ipv6` route lists on other subnet groups target the effective attachment.
7373

74+
Optional attachment arguments: `routing_policy_label` applies a routing policy label for traffic routing decisions, and `dns_support` / `security_group_referencing` map to the attachment options block. All three default to `null`, deferring to the AWS service defaults so existing attachments see no diff.
75+
7476
## Cloud WAN acceptance ownership
7577

7678
Acceptance is an explicit lifecycle boundary:
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
}

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ variable "subnets" {
612612
accept_attachment = optional(bool, false)
613613
create_accepter = optional(bool, true)
614614
accepter_id = optional(string)
615+
# null defers to the AWS service defaults so existing attachments see no diff
616+
dns_support = optional(bool)
617+
security_group_referencing = optional(bool)
618+
routing_policy_label = optional(string)
615619
}))
616620
}))
617621

0 commit comments

Comments
 (0)