Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: aws_vpn_connection removes transit gateway id dependency for IPv6 tunnel options #36405

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/36405.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_vpn_connection: `local_ipv6_network_cidr`, `remote_ipv6_network_cidr`, `tunnel1_inside_ipv6_cidr`, and `tunnel2_inside_ipv6_cidr` no longer require `transit_gateway_id` to be specified
```
6 changes: 6 additions & 0 deletions internal/service/ec2/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ec2

// Exports for use in tests only.
var (
ResourceCustomerGateway = resourceCustomerGateway
ResourceDefaultNetworkACL = resourceDefaultNetworkACL
ResourceDefaultRouteTable = resourceDefaultRouteTable
ResourceEBSFastSnapshotRestore = newResourceEBSFastSnapshotRestore
Expand All @@ -17,6 +18,11 @@ var (
ResourceSecurityGroupIngressRule = newResourceSecurityGroupIngressRule
ResourceTag = resourceTag
ResourceTransitGatewayPeeringAttachment = resourceTransitGatewayPeeringAttachment
ResourceVPNConnection = resourceVPNConnection
ResourceVPNConnectionRoute = resourceVPNConnectionRoute
ResourceVPNGateway = resourceVPNGateway
ResourceVPNGatewayAttachment = resourceVPNGatewayAttachment
ResourceVPNGatewayRoutePropagation = resourceVPNGatewayRoutePropagation

CustomFiltersSchema = customFiltersSchema
FindEBSFastSnapshotRestoreByID = findEBSFastSnapshotRestoreByID
Expand Down
21 changes: 13 additions & 8 deletions internal/service/ec2/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/service/ec2/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ func sweepVPNConnections(region string) error {
continue
}

r := ResourceVPNConnection()
r := resourceVPNConnection()
d := r.Data(nil)
d.SetId(aws.StringValue(v.VpnConnectionId))

Expand Down Expand Up @@ -2617,7 +2617,7 @@ func sweepVPNGateways(region string) error {
continue
}

r := ResourceVPNGateway()
r := resourceVPNGateway()
d := r.Data(nil)
d.SetId(aws.StringValue(v.VpnGatewayId))

Expand Down Expand Up @@ -2667,7 +2667,7 @@ func sweepCustomerGateways(region string) error {
continue
}

r := ResourceCustomerGateway()
r := resourceCustomerGateway()
d := r.Data(nil)
d.SetId(aws.StringValue(v.CustomerGatewayId))

Expand Down
6 changes: 1 addition & 5 deletions internal/service/ec2/vpnsite_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

// @SDKResource("aws_vpn_connection", name="VPN Connection")
// @Tags(identifierAttribute="id")
func ResourceVPNConnection() *schema.Resource {
func resourceVPNConnection() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceVPNConnectionCreate,
ReadWithoutTimeout: resourceVPNConnectionRead,
Expand Down Expand Up @@ -83,7 +83,6 @@ func ResourceVPNConnection() *schema.Resource {
Optional: true,
Computed: true,
ValidateFunc: validation.IsCIDRNetwork(0, 128),
RequiredWith: []string{"transit_gateway_id"},
},
"outside_ip_address_type": {
Type: schema.TypeString,
Expand All @@ -102,7 +101,6 @@ func ResourceVPNConnection() *schema.Resource {
Optional: true,
Computed: true,
ValidateFunc: validation.IsCIDRNetwork(0, 128),
RequiredWith: []string{"transit_gateway_id"},
},
"routes": {
Type: schema.TypeSet,
Expand Down Expand Up @@ -215,7 +213,6 @@ func ResourceVPNConnection() *schema.Resource {
Computed: true,
ForceNew: true,
ValidateFunc: validVPNConnectionTunnelInsideIPv6CIDR(),
RequiredWith: []string{"transit_gateway_id"},
},
"tunnel1_log_options": {
Type: schema.TypeList,
Expand Down Expand Up @@ -432,7 +429,6 @@ func ResourceVPNConnection() *schema.Resource {
Computed: true,
ForceNew: true,
ValidateFunc: validVPNConnectionTunnelInsideIPv6CIDR(),
RequiredWith: []string{"transit_gateway_id"},
},
"tunnel2_log_options": {
Type: schema.TypeList,
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpnsite_connection_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

// @SDKResource("aws_vpn_connection_route")
func ResourceVPNConnectionRoute() *schema.Resource {
// @SDKResource("aws_vpn_connection_route", name="VPN Connection Route")
func resourceVPNConnectionRoute() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceVPNConnectionRouteCreate,
ReadWithoutTimeout: resourceVPNConnectionRouteRead,
Expand Down
5 changes: 0 additions & 5 deletions internal/service/ec2/vpnsite_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2374,10 +2374,6 @@ resource "aws_vpn_connection" "test" {

func testAccSiteVPNConnectionConfig_tunnel1InsideIPv6CIDR(rName string, rBgpAsn int, tunnel1InsideIpv6Cidr string, tunnel2InsideIpv6Cidr string) string {
return fmt.Sprintf(`
resource "aws_ec2_transit_gateway" "test" {
description = %[1]q
}

resource "aws_customer_gateway" "test" {
bgp_asn = %[2]d
ip_address = "178.0.0.1"
Expand All @@ -2390,7 +2386,6 @@ resource "aws_customer_gateway" "test" {

resource "aws_vpn_connection" "test" {
customer_gateway_id = aws_customer_gateway.test.id
transit_gateway_id = aws_ec2_transit_gateway.test.id
tunnel_inside_ip_version = "ipv6"
tunnel1_inside_ipv6_cidr = %[3]q
tunnel2_inside_ipv6_cidr = %[4]q
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/vpnsite_customer_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

// @SDKResource("aws_customer_gateway", name="Customer Gateway")
// @Tags(identifierAttribute="id")
func ResourceCustomerGateway() *schema.Resource {
func resourceCustomerGateway() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceCustomerGatewayCreate,
ReadWithoutTimeout: resourceCustomerGatewayRead,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

// @SDKDataSource("aws_customer_gateway")
func DataSourceCustomerGateway() *schema.Resource {
// @SDKDataSource("aws_customer_gateway", name="Customer Gateway")
func dataSourceCustomerGateway() *schema.Resource {
return &schema.Resource{
ReadWithoutTimeout: dataSourceCustomerGatewayRead,

Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/vpnsite_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

// @SDKResource("aws_vpn_gateway", name="VPN Gateway")
// @Tags(identifierAttribute="id")
func ResourceVPNGateway() *schema.Resource {
func resourceVPNGateway() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceVPNGatewayCreate,
ReadWithoutTimeout: resourceVPNGatewayRead,
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpnsite_gateway_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

// @SDKResource("aws_vpn_gateway_attachment")
func ResourceVPNGatewayAttachment() *schema.Resource {
// @SDKResource("aws_vpn_gateway_attachment", name="VPN Gateway Attachment")
func resourceVPNGatewayAttachment() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceVPNGatewayAttachmentCreate,
ReadWithoutTimeout: resourceVPNGatewayAttachmentRead,
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpnsite_gateway_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

// @SDKDataSource("aws_vpn_gateway")
func DataSourceVPNGateway() *schema.Resource {
// @SDKDataSource("aws_vpn_gateway", name="VPN Gateway")
func dataSourceVPNGateway() *schema.Resource {
return &schema.Resource{
ReadWithoutTimeout: dataSourceVPNGatewayRead,

Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpnsite_gateway_route_propagation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

// @SDKResource("aws_vpn_gateway_route_propagation")
func ResourceVPNGatewayRoutePropagation() *schema.Resource {
// @SDKResource("aws_vpn_gateway_route_propagation", name="VPN Gateway Route Propagation")
func resourceVPNGatewayRoutePropagation() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceVPNGatewayRoutePropagationEnable,
ReadWithoutTimeout: resourceVPNGatewayRoutePropagationRead,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
tfec2 "github.com/hashicorp/terraform-provider-aws/internal/service/ec2"
tfnetworkmanager "github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/names"
Expand All @@ -23,9 +22,8 @@ func TestAccNetworkManagerCustomerGatewayAssociation_serial(t *testing.T) {
t.Parallel()

testCases := map[string]func(t *testing.T){
"basic": testAccCustomerGatewayAssociation_basic,
"disappears": testAccCustomerGatewayAssociation_disappears,
"disappears_CustomerGateway": testAccCustomerGatewayAssociation_Disappears_customerGateway,
"basic": testAccCustomerGatewayAssociation_basic,
"disappears": testAccCustomerGatewayAssociation_disappears,
}

acctest.RunSerialTests1Level(t, testCases, 0)
Expand Down Expand Up @@ -80,32 +78,6 @@ func testAccCustomerGatewayAssociation_disappears(t *testing.T) {
})
}

func testAccCustomerGatewayAssociation_Disappears_customerGateway(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_networkmanager_customer_gateway_association.test"
vpnConnectionResourceName := "aws_vpn_connection.test"
customerGatewayResourceName := "aws_customer_gateway.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.NetworkManagerServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckCustomerGatewayAssociationDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccCustomerGatewayAssociationConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckCustomerGatewayAssociationExists(ctx, resourceName),
acctest.CheckResourceDisappears(ctx, acctest.Provider, tfec2.ResourceVPNConnection(), vpnConnectionResourceName),
acctest.CheckResourceDisappears(ctx, acctest.Provider, tfec2.ResourceCustomerGateway(), customerGatewayResourceName),
),
ExpectNonEmptyPlan: true,
},
},
})
}

func testAccCheckCustomerGatewayAssociationDestroy(ctx context.Context) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := acctest.Provider.Meta().(*conns.AWSClient).NetworkManagerConn(ctx)
Expand Down
Loading