From a3116df0862dc3631405f2803863091f384d9411 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 1 Aug 2024 12:39:56 -0400 Subject: [PATCH] Run 'make fix-constants PKG=directconnect'. --- internal/service/directconnect/gateway.go | 14 +-- .../directconnect/gateway_data_source.go | 8 +- .../directconnect/hosted_connection.go | 32 +++---- .../hosted_private_virtual_interface.go | 22 ++--- .../hosted_private_virtual_interface_test.go | 54 ++++++------ .../hosted_public_virtual_interface.go | 22 ++--- .../hosted_public_virtual_interface_test.go | 42 ++++----- .../hosted_transit_virtual_interface.go | 22 ++--- .../hosted_transit_virtual_interface_test.go | 56 ++++++------ .../private_virtual_interface.go | 16 ++-- .../private_virtual_interface_test.go | 88 +++++++++---------- .../directconnect/public_virtual_interface.go | 16 ++-- .../public_virtual_interface_test.go | 30 +++---- .../transit_virtual_interface.go | 16 ++-- .../transit_virtual_interface_test.go | 78 ++++++++-------- 15 files changed, 258 insertions(+), 258 deletions(-) diff --git a/internal/service/directconnect/gateway.go b/internal/service/directconnect/gateway.go index 6c05fa48cb6..aac0aab1122 100644 --- a/internal/service/directconnect/gateway.go +++ b/internal/service/directconnect/gateway.go @@ -40,11 +40,11 @@ func ResourceGateway() *schema.Resource { ForceNew: true, ValidateFunc: verify.ValidAmazonSideASN, }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, }, - "owner_account_id": { + names.AttrOwnerAccountID: { Type: schema.TypeString, Computed: true, }, @@ -61,7 +61,7 @@ func resourceGatewayCreate(ctx context.Context, d *schema.ResourceData, meta int var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) - name := d.Get("name").(string) + name := d.Get(names.AttrName).(string) input := &directconnect.CreateDirectConnectGatewayInput{ DirectConnectGatewayName: aws.String(name), } @@ -103,8 +103,8 @@ func resourceGatewayRead(ctx context.Context, d *schema.ResourceData, meta inter } d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(output.AmazonSideAsn), 10)) - d.Set("name", output.DirectConnectGatewayName) - d.Set("owner_account_id", output.OwnerAccount) + d.Set(names.AttrName, output.DirectConnectGatewayName) + d.Set(names.AttrOwnerAccountID, output.OwnerAccount) return diags } @@ -113,10 +113,10 @@ func resourceGatewayUpdate(ctx context.Context, d *schema.ResourceData, meta int var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) - if d.HasChange("name") { + if d.HasChange(names.AttrName) { input := &directconnect.UpdateDirectConnectGatewayInput{ DirectConnectGatewayId: aws.String(d.Id()), - NewDirectConnectGatewayName: aws.String(d.Get("name").(string)), + NewDirectConnectGatewayName: aws.String(d.Get(names.AttrName).(string)), } _, err := conn.UpdateDirectConnectGateway(ctx, input) diff --git a/internal/service/directconnect/gateway_data_source.go b/internal/service/directconnect/gateway_data_source.go index a5c4ec8ebb8..27d5169c1d2 100644 --- a/internal/service/directconnect/gateway_data_source.go +++ b/internal/service/directconnect/gateway_data_source.go @@ -26,11 +26,11 @@ func DataSourceGateway() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, }, - "owner_account_id": { + names.AttrOwnerAccountID: { Type: schema.TypeString, Computed: true, }, @@ -41,7 +41,7 @@ func DataSourceGateway() *schema.Resource { func dataSourceGatewayRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) - name := d.Get("name").(string) + name := d.Get(names.AttrName).(string) gateways := make([]awstypes.DirectConnectGateway, 0) // DescribeDirectConnectGatewaysInput does not have a name parameter for filtering @@ -74,7 +74,7 @@ func dataSourceGatewayRead(ctx context.Context, d *schema.ResourceData, meta int d.SetId(aws.ToString(gateway.DirectConnectGatewayId)) d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(gateway.AmazonSideAsn), 10)) - d.Set("owner_account_id", gateway.OwnerAccount) + d.Set(names.AttrOwnerAccountID, gateway.OwnerAccount) return diags } diff --git a/internal/service/directconnect/hosted_connection.go b/internal/service/directconnect/hosted_connection.go index f11be99bebb..2e4e3519d78 100644 --- a/internal/service/directconnect/hosted_connection.go +++ b/internal/service/directconnect/hosted_connection.go @@ -37,7 +37,7 @@ func ResourceHostedConnection() *schema.Resource { ForceNew: true, ValidateFunc: validConnectionBandWidth(), }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -58,16 +58,16 @@ func ResourceHostedConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "location": { + names.AttrLocation: { Type: schema.TypeString, Computed: true, }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, }, - "owner_account_id": { + names.AttrOwnerAccountID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -77,15 +77,15 @@ func ResourceHostedConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Computed: true, }, - "region": { + names.AttrRegion: { Type: schema.TypeString, Computed: true, }, - "state": { + names.AttrState: { Type: schema.TypeString, Computed: true, }, @@ -103,12 +103,12 @@ func resourceHostedConnectionCreate(ctx context.Context, d *schema.ResourceData, var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) - name := d.Get("name").(string) + name := d.Get(names.AttrName).(string) input := &directconnect.AllocateHostedConnectionInput{ Bandwidth: aws.String(d.Get("bandwidth").(string)), - ConnectionId: aws.String(d.Get("connection_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), ConnectionName: aws.String(name), - OwnerAccount: aws.String(d.Get("owner_account_id").(string)), + OwnerAccount: aws.String(d.Get(names.AttrOwnerAccountID).(string)), Vlan: int32(d.Get("vlan").(int)), } @@ -148,13 +148,13 @@ func resourceHostedConnectionRead(ctx context.Context, d *schema.ResourceData, m d.Set("jumbo_frame_capable", connection.JumboFrameCapable) d.Set("lag_id", connection.LagId) d.Set("loa_issue_time", aws.ToTime(connection.LoaIssueTime).Format(time.RFC3339)) - d.Set("location", connection.Location) - d.Set("name", connection.ConnectionName) - d.Set("owner_account_id", connection.OwnerAccount) + d.Set(names.AttrLocation, connection.Location) + d.Set(names.AttrName, connection.ConnectionName) + d.Set(names.AttrOwnerAccountID, connection.OwnerAccount) d.Set("partner_name", connection.PartnerName) - d.Set("provider_name", connection.ProviderName) - d.Set("region", connection.Region) - d.Set("state", connection.ConnectionState) + d.Set(names.AttrProviderName, connection.ProviderName) + d.Set(names.AttrRegion, connection.Region) + d.Set(names.AttrState, connection.ConnectionState) d.Set("vlan", connection.Vlan) return diags diff --git a/internal/service/directconnect/hosted_private_virtual_interface.go b/internal/service/directconnect/hosted_private_virtual_interface.go index 7d66f982218..714efffdf02 100644 --- a/internal/service/directconnect/hosted_private_virtual_interface.go +++ b/internal/service/directconnect/hosted_private_virtual_interface.go @@ -46,7 +46,7 @@ func ResourceHostedPrivateVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "arn": { + names.AttrARN: { Type: schema.TypeString, Computed: true, }, @@ -69,7 +69,7 @@ func ResourceHostedPrivateVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -91,12 +91,12 @@ func ResourceHostedPrivateVirtualInterface() *schema.Resource { ForceNew: true, ValidateFunc: validation.IntInSlice([]int{1500, 9001}), }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, }, - "owner_account_id": { + names.AttrOwnerAccountID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -122,15 +122,15 @@ func resourceHostedPrivateVirtualInterfaceCreate(ctx context.Context, d *schema. conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) req := &directconnect.AllocatePrivateVirtualInterfaceInput{ - ConnectionId: aws.String(d.Get("connection_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), NewPrivateVirtualInterfaceAllocation: &awstypes.NewPrivateVirtualInterfaceAllocation{ AddressFamily: awstypes.AddressFamily(d.Get("address_family").(string)), Asn: int32(d.Get("bgp_asn").(int)), Mtu: aws.Int32(int32(d.Get("mtu").(int))), - VirtualInterfaceName: aws.String(d.Get("name").(string)), + VirtualInterfaceName: aws.String(d.Get(names.AttrName).(string)), Vlan: int32(d.Get("vlan").(int)), }, - OwnerAccount: aws.String(d.Get("owner_account_id").(string)), + OwnerAccount: aws.String(d.Get(names.AttrOwnerAccountID).(string)), } if v, ok := d.GetOk("amazon_address"); ok { req.NewPrivateVirtualInterfaceAllocation.AmazonAddress = aws.String(v.(string)) @@ -184,16 +184,16 @@ func resourceHostedPrivateVirtualInterfaceRead(ctx context.Context, d *schema.Re AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("dxvif/%s", d.Id()), }.String() - d.Set("arn", arn) + d.Set(names.AttrARN, arn) d.Set("aws_device", vif.AwsDeviceV2) d.Set("bgp_asn", vif.Asn) d.Set("bgp_auth_key", vif.AuthKey) - d.Set("connection_id", vif.ConnectionId) + d.Set(names.AttrConnectionID, vif.ConnectionId) d.Set("customer_address", vif.CustomerAddress) d.Set("jumbo_frame_capable", vif.JumboFrameCapable) d.Set("mtu", vif.Mtu) - d.Set("name", vif.VirtualInterfaceName) - d.Set("owner_account_id", vif.OwnerAccount) + d.Set(names.AttrName, vif.VirtualInterfaceName) + d.Set(names.AttrOwnerAccountID, vif.OwnerAccount) d.Set("vlan", vif.Vlan) return diags diff --git a/internal/service/directconnect/hosted_private_virtual_interface_test.go b/internal/service/directconnect/hosted_private_virtual_interface_test.go index 70317ac6e27..7c488d37f01 100644 --- a/internal/service/directconnect/hosted_private_virtual_interface_test.go +++ b/internal/service/directconnect/hosted_private_virtual_interface_test.go @@ -51,21 +51,21 @@ func TestAccDirectConnectHostedPrivateVirtualInterface_basic(t *testing.T) { testAccCheckHostedPrivateVirtualInterfaceExists(ctx, resourceName, &vif), resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttrSet(resourceName, "owner_account_id"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrOwnerAccountID), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "0"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), - resource.TestCheckResourceAttrPair(accepterResourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct0), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), + resource.TestCheckResourceAttrPair(accepterResourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, // Test import. @@ -110,24 +110,24 @@ func TestAccDirectConnectHostedPrivateVirtualInterface_accepterTags(t *testing.T testAccCheckHostedPrivateVirtualInterfaceExists(ctx, resourceName, &vif), resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttrSet(resourceName, "owner_account_id"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrOwnerAccountID), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "3"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(accepterResourceName, "tags.Name", rName), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key1", "Value1"), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key2", "Value2a"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), - resource.TestCheckResourceAttrPair(accepterResourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), + resource.TestCheckResourceAttrPair(accepterResourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, { @@ -136,24 +136,24 @@ func TestAccDirectConnectHostedPrivateVirtualInterface_accepterTags(t *testing.T testAccCheckHostedPrivateVirtualInterfaceExists(ctx, resourceName, &vif), resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttrSet(resourceName, "owner_account_id"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrOwnerAccountID), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "3"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(accepterResourceName, "tags.Name", rName), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key2", "Value2b"), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key3", "Value3"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), - resource.TestCheckResourceAttrPair(accepterResourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), + resource.TestCheckResourceAttrPair(accepterResourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, }, diff --git a/internal/service/directconnect/hosted_public_virtual_interface.go b/internal/service/directconnect/hosted_public_virtual_interface.go index 6eadfe71f99..37ce43b65d9 100644 --- a/internal/service/directconnect/hosted_public_virtual_interface.go +++ b/internal/service/directconnect/hosted_public_virtual_interface.go @@ -51,7 +51,7 @@ func ResourceHostedPublicVirtualInterface() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "arn": { + names.AttrARN: { Type: schema.TypeString, Computed: true, }, @@ -70,7 +70,7 @@ func ResourceHostedPublicVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -81,12 +81,12 @@ func ResourceHostedPublicVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, }, - "owner_account_id": { + names.AttrOwnerAccountID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -119,14 +119,14 @@ func resourceHostedPublicVirtualInterfaceCreate(ctx context.Context, d *schema.R conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) req := &directconnect.AllocatePublicVirtualInterfaceInput{ - ConnectionId: aws.String(d.Get("connection_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), NewPublicVirtualInterfaceAllocation: &awstypes.NewPublicVirtualInterfaceAllocation{ AddressFamily: awstypes.AddressFamily(d.Get("address_family").(string)), Asn: int32(d.Get("bgp_asn").(int)), - VirtualInterfaceName: aws.String(d.Get("name").(string)), + VirtualInterfaceName: aws.String(d.Get(names.AttrName).(string)), Vlan: int32(d.Get("vlan").(int)), }, - OwnerAccount: aws.String(d.Get("owner_account_id").(string)), + OwnerAccount: aws.String(d.Get(names.AttrOwnerAccountID).(string)), } if v, ok := d.GetOk("amazon_address"); ok { req.NewPublicVirtualInterfaceAllocation.AmazonAddress = aws.String(v.(string)) @@ -180,14 +180,14 @@ func resourceHostedPublicVirtualInterfaceRead(ctx context.Context, d *schema.Res AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("dxvif/%s", d.Id()), }.String() - d.Set("arn", arn) + d.Set(names.AttrARN, arn) d.Set("aws_device", vif.AwsDeviceV2) d.Set("bgp_asn", vif.Asn) d.Set("bgp_auth_key", vif.AuthKey) - d.Set("connection_id", vif.ConnectionId) + d.Set(names.AttrConnectionID, vif.ConnectionId) d.Set("customer_address", vif.CustomerAddress) - d.Set("name", vif.VirtualInterfaceName) - d.Set("owner_account_id", vif.OwnerAccount) + d.Set(names.AttrName, vif.VirtualInterfaceName) + d.Set(names.AttrOwnerAccountID, vif.OwnerAccount) if err := d.Set("route_filter_prefixes", flattenRouteFilterPrefixes(vif.RouteFilterPrefixes)); err != nil { return sdkdiag.AppendErrorf(diags, "setting route_filter_prefixes: %s", err) } diff --git a/internal/service/directconnect/hosted_public_virtual_interface_test.go b/internal/service/directconnect/hosted_public_virtual_interface_test.go index ac2d20aa5cc..89a7b259bb4 100644 --- a/internal/service/directconnect/hosted_public_virtual_interface_test.go +++ b/internal/service/directconnect/hosted_public_virtual_interface_test.go @@ -53,21 +53,21 @@ func TestAccDirectConnectHostedPublicVirtualInterface_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttr(resourceName, "customer_address", customerAddress), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", "2"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", acctest.Ct2), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "210.52.109.0/24"), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "175.45.176.0/22"), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "0"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct0), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), ), }, // Test import. @@ -114,24 +114,24 @@ func TestAccDirectConnectHostedPublicVirtualInterface_accepterTags(t *testing.T) resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttr(resourceName, "amazon_address", amazonAddress), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttr(resourceName, "customer_address", customerAddress), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", "2"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", acctest.Ct2), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "210.52.109.0/24"), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "175.45.176.0/22"), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "3"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(accepterResourceName, "tags.Name", rName), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key1", "Value1"), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key2", "Value2a"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), ), }, { @@ -141,24 +141,24 @@ func TestAccDirectConnectHostedPublicVirtualInterface_accepterTags(t *testing.T) resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttr(resourceName, "amazon_address", amazonAddress), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttr(resourceName, "customer_address", customerAddress), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", "2"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", acctest.Ct2), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "210.52.109.0/24"), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "175.45.176.0/22"), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "3"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(accepterResourceName, "tags.Name", rName), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key2", "Value2b"), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key3", "Value3"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), ), }, }, diff --git a/internal/service/directconnect/hosted_transit_virtual_interface.go b/internal/service/directconnect/hosted_transit_virtual_interface.go index 5ec52561824..d6c83810375 100644 --- a/internal/service/directconnect/hosted_transit_virtual_interface.go +++ b/internal/service/directconnect/hosted_transit_virtual_interface.go @@ -50,7 +50,7 @@ func ResourceHostedTransitVirtualInterface() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "arn": { + names.AttrARN: { Type: schema.TypeString, Computed: true, }, @@ -69,7 +69,7 @@ func ResourceHostedTransitVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -91,12 +91,12 @@ func ResourceHostedTransitVirtualInterface() *schema.Resource { ForceNew: true, ValidateFunc: validation.IntInSlice([]int{1500, 8500}), }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, }, - "owner_account_id": { + names.AttrOwnerAccountID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -122,13 +122,13 @@ func resourceHostedTransitVirtualInterfaceCreate(ctx context.Context, d *schema. conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) req := &directconnect.AllocateTransitVirtualInterfaceInput{ - ConnectionId: aws.String(d.Get("connection_id").(string)), - OwnerAccount: aws.String(d.Get("owner_account_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), + OwnerAccount: aws.String(d.Get(names.AttrOwnerAccountID).(string)), NewTransitVirtualInterfaceAllocation: &awstypes.NewTransitVirtualInterfaceAllocation{ AddressFamily: awstypes.AddressFamily(d.Get("address_family").(string)), Asn: int32(d.Get("bgp_asn").(int)), Mtu: aws.Int32(int32(d.Get("mtu").(int))), - VirtualInterfaceName: aws.String(d.Get("name").(string)), + VirtualInterfaceName: aws.String(d.Get(names.AttrName).(string)), Vlan: int32(d.Get("vlan").(int)), }, } @@ -181,16 +181,16 @@ func resourceHostedTransitVirtualInterfaceRead(ctx context.Context, d *schema.Re AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("dxvif/%s", d.Id()), }.String() - d.Set("arn", arn) + d.Set(names.AttrARN, arn) d.Set("aws_device", vif.AwsDeviceV2) d.Set("bgp_asn", vif.Asn) d.Set("bgp_auth_key", vif.AuthKey) - d.Set("connection_id", vif.ConnectionId) + d.Set(names.AttrConnectionID, vif.ConnectionId) d.Set("customer_address", vif.CustomerAddress) d.Set("jumbo_frame_capable", vif.JumboFrameCapable) d.Set("mtu", vif.Mtu) - d.Set("name", vif.VirtualInterfaceName) - d.Set("owner_account_id", vif.OwnerAccount) + d.Set(names.AttrName, vif.VirtualInterfaceName) + d.Set(names.AttrOwnerAccountID, vif.OwnerAccount) d.Set("vlan", vif.Vlan) return diags diff --git a/internal/service/directconnect/hosted_transit_virtual_interface_test.go b/internal/service/directconnect/hosted_transit_virtual_interface_test.go index 3a27bd15a91..98903477924 100644 --- a/internal/service/directconnect/hosted_transit_virtual_interface_test.go +++ b/internal/service/directconnect/hosted_transit_virtual_interface_test.go @@ -24,7 +24,7 @@ func TestAccDirectConnectHostedTransitVirtualInterface_serial(t *testing.T) { t.Parallel() testCases := map[string]func(t *testing.T){ - "basic": testAccHostedTransitVirtualInterface_basic, + acctest.CtBasic: testAccHostedTransitVirtualInterface_basic, "accepterTags": testAccHostedTransitVirtualInterface_accepterTags, } @@ -63,21 +63,21 @@ func testAccHostedTransitVirtualInterface_basic(t *testing.T) { testAccCheckHostedTransitVirtualInterfaceExists(ctx, resourceName, &vif), resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttrSet(resourceName, "owner_account_id"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrOwnerAccountID), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttrPair(accepterResourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "0"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(accepterResourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct0), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), ), }, // Test import. @@ -123,24 +123,24 @@ func testAccHostedTransitVirtualInterface_accepterTags(t *testing.T) { testAccCheckHostedTransitVirtualInterfaceExists(ctx, resourceName, &vif), resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttrSet(resourceName, "owner_account_id"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrOwnerAccountID), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttrPair(accepterResourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "3"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(accepterResourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(accepterResourceName, "tags.Name", rName), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key1", "Value1"), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key2", "Value2a"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), ), }, { @@ -149,24 +149,24 @@ func testAccHostedTransitVirtualInterface_accepterTags(t *testing.T) { testAccCheckHostedTransitVirtualInterfaceExists(ctx, resourceName, &vif), resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttrSet(resourceName, "owner_account_id"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrOwnerAccountID), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), // Accepter's attributes: - resource.TestCheckResourceAttrSet(accepterResourceName, "arn"), - resource.TestCheckResourceAttrPair(accepterResourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(accepterResourceName, "tags.%", "3"), + resource.TestCheckResourceAttrSet(accepterResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(accepterResourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(accepterResourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(accepterResourceName, "tags.Name", rName), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key2", "Value2b"), resource.TestCheckResourceAttr(accepterResourceName, "tags.Key3", "Value3"), - resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, "id"), + resource.TestCheckResourceAttrPair(accepterResourceName, "virtual_interface_id", resourceName, names.AttrID), ), }, }, diff --git a/internal/service/directconnect/private_virtual_interface.go b/internal/service/directconnect/private_virtual_interface.go index 9ab956f7db3..12de5bbc966 100644 --- a/internal/service/directconnect/private_virtual_interface.go +++ b/internal/service/directconnect/private_virtual_interface.go @@ -54,7 +54,7 @@ func ResourcePrivateVirtualInterface() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "arn": { + names.AttrARN: { Type: schema.TypeString, Computed: true, }, @@ -73,7 +73,7 @@ func ResourcePrivateVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -100,7 +100,7 @@ func ResourcePrivateVirtualInterface() *schema.Resource { Optional: true, ValidateFunc: validation.IntInSlice([]int{1500, 9001}), }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -146,14 +146,14 @@ func resourcePrivateVirtualInterfaceCreate(ctx context.Context, d *schema.Resour } req := &directconnect.CreatePrivateVirtualInterfaceInput{ - ConnectionId: aws.String(d.Get("connection_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), NewPrivateVirtualInterface: &awstypes.NewPrivateVirtualInterface{ AddressFamily: awstypes.AddressFamily(d.Get("address_family").(string)), Asn: int32(d.Get("bgp_asn").(int)), EnableSiteLink: aws.Bool(d.Get("sitelink_enabled").(bool)), Mtu: aws.Int32(int32(d.Get("mtu").(int))), Tags: getTagsIn(ctx), - VirtualInterfaceName: aws.String(d.Get("name").(string)), + VirtualInterfaceName: aws.String(d.Get(names.AttrName).(string)), Vlan: int32(d.Get("vlan").(int)), }, } @@ -212,16 +212,16 @@ func resourcePrivateVirtualInterfaceRead(ctx context.Context, d *schema.Resource AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("dxvif/%s", d.Id()), }.String() - d.Set("arn", arn) + d.Set(names.AttrARN, arn) d.Set("aws_device", vif.AwsDeviceV2) d.Set("bgp_asn", vif.Asn) d.Set("bgp_auth_key", vif.AuthKey) - d.Set("connection_id", vif.ConnectionId) + d.Set(names.AttrConnectionID, vif.ConnectionId) d.Set("customer_address", vif.CustomerAddress) d.Set("dx_gateway_id", vif.DirectConnectGatewayId) d.Set("jumbo_frame_capable", vif.JumboFrameCapable) d.Set("mtu", vif.Mtu) - d.Set("name", vif.VirtualInterfaceName) + d.Set(names.AttrName, vif.VirtualInterfaceName) d.Set("sitelink_enabled", vif.SiteLinkEnabled) d.Set("vlan", vif.Vlan) d.Set("vpn_gateway_id", vif.VirtualGatewayId) diff --git a/internal/service/directconnect/private_virtual_interface_test.go b/internal/service/directconnect/private_virtual_interface_test.go index 5a308cf7f1b..cbb6a965333 100644 --- a/internal/service/directconnect/private_virtual_interface_test.go +++ b/internal/service/directconnect/private_virtual_interface_test.go @@ -48,18 +48,18 @@ func TestAccDirectConnectPrivateVirtualInterface_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), - resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, { @@ -69,18 +69,18 @@ func TestAccDirectConnectPrivateVirtualInterface_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "9001"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), - resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, // Test import. @@ -121,21 +121,21 @@ func TestAccDirectConnectPrivateVirtualInterface_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "tags.Key1", "Value1"), resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2a"), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), - resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, { @@ -145,21 +145,21 @@ func TestAccDirectConnectPrivateVirtualInterface_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2b"), resource.TestCheckResourceAttr(resourceName, "tags.Key3", "Value3"), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), - resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, "id"), + resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", vpnGatewayResourceName, names.AttrID), ), }, // Test import. @@ -201,17 +201,17 @@ func TestAccDirectConnectPrivateVirtualInterface_dxGateway(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), ), }, @@ -254,19 +254,19 @@ func TestAccDirectConnectPrivateVirtualInterface_siteLink(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), - resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", acctest.CtTrue), ), }, { @@ -276,19 +276,19 @@ func TestAccDirectConnectPrivateVirtualInterface_siteLink(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), - resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", "false"), + resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", acctest.CtFalse), ), }, // Test import. diff --git a/internal/service/directconnect/public_virtual_interface.go b/internal/service/directconnect/public_virtual_interface.go index 5397ea57c89..7249d9398ce 100644 --- a/internal/service/directconnect/public_virtual_interface.go +++ b/internal/service/directconnect/public_virtual_interface.go @@ -59,7 +59,7 @@ func ResourcePublicVirtualInterface() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "arn": { + names.AttrARN: { Type: schema.TypeString, Computed: true, }, @@ -78,7 +78,7 @@ func ResourcePublicVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -89,7 +89,7 @@ func ResourcePublicVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -123,12 +123,12 @@ func resourcePublicVirtualInterfaceCreate(ctx context.Context, d *schema.Resourc conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) req := &directconnect.CreatePublicVirtualInterfaceInput{ - ConnectionId: aws.String(d.Get("connection_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), NewPublicVirtualInterface: &awstypes.NewPublicVirtualInterface{ AddressFamily: awstypes.AddressFamily(d.Get("address_family").(string)), Asn: int32(d.Get("bgp_asn").(int)), Tags: getTagsIn(ctx), - VirtualInterfaceName: aws.String(d.Get("name").(string)), + VirtualInterfaceName: aws.String(d.Get(names.AttrName).(string)), Vlan: int32(d.Get("vlan").(int)), }, } @@ -184,13 +184,13 @@ func resourcePublicVirtualInterfaceRead(ctx context.Context, d *schema.ResourceD AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("dxvif/%s", d.Id()), }.String() - d.Set("arn", arn) + d.Set(names.AttrARN, arn) d.Set("aws_device", vif.AwsDeviceV2) d.Set("bgp_asn", vif.Asn) d.Set("bgp_auth_key", vif.AuthKey) d.Set("customer_address", vif.CustomerAddress) - d.Set("connection_id", vif.ConnectionId) - d.Set("name", vif.VirtualInterfaceName) + d.Set(names.AttrConnectionID, vif.ConnectionId) + d.Set(names.AttrName, vif.VirtualInterfaceName) if err := d.Set("route_filter_prefixes", flattenRouteFilterPrefixes(vif.RouteFilterPrefixes)); err != nil { return sdkdiag.AppendErrorf(diags, "setting route_filter_prefixes: %s", err) } diff --git a/internal/service/directconnect/public_virtual_interface_test.go b/internal/service/directconnect/public_virtual_interface_test.go index 63c5feb95b8..654684e0f99 100644 --- a/internal/service/directconnect/public_virtual_interface_test.go +++ b/internal/service/directconnect/public_virtual_interface_test.go @@ -53,17 +53,17 @@ func TestAccDirectConnectPublicVirtualInterface_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttr(resourceName, "amazon_address", amazonAddress), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttr(resourceName, "customer_address", customerAddress), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", "2"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", acctest.Ct2), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "210.52.109.0/24"), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "175.45.176.0/22"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), ), }, @@ -106,17 +106,17 @@ func TestAccDirectConnectPublicVirtualInterface_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttr(resourceName, "amazon_address", amazonAddress), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttr(resourceName, "customer_address", customerAddress), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", "2"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", acctest.Ct2), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "210.52.109.0/24"), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "175.45.176.0/22"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "3"), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "tags.Key1", "Value1"), resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2a"), @@ -130,17 +130,17 @@ func TestAccDirectConnectPublicVirtualInterface_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttr(resourceName, "amazon_address", amazonAddress), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttr(resourceName, "customer_address", customerAddress), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", "2"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "route_filter_prefixes.#", acctest.Ct2), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "210.52.109.0/24"), resource.TestCheckTypeSetElemAttr(resourceName, "route_filter_prefixes.*", "175.45.176.0/22"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "3"), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2b"), resource.TestCheckResourceAttr(resourceName, "tags.Key3", "Value3"), diff --git a/internal/service/directconnect/transit_virtual_interface.go b/internal/service/directconnect/transit_virtual_interface.go index 58d7b383935..bd4ffeebea7 100644 --- a/internal/service/directconnect/transit_virtual_interface.go +++ b/internal/service/directconnect/transit_virtual_interface.go @@ -54,7 +54,7 @@ func ResourceTransitVirtualInterface() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "arn": { + names.AttrARN: { Type: schema.TypeString, Computed: true, }, @@ -73,7 +73,7 @@ func ResourceTransitVirtualInterface() *schema.Resource { Computed: true, ForceNew: true, }, - "connection_id": { + names.AttrConnectionID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -99,7 +99,7 @@ func ResourceTransitVirtualInterface() *schema.Resource { Optional: true, ValidateFunc: validation.IntInSlice([]int{1500, 8500}), }, - "name": { + names.AttrName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -133,7 +133,7 @@ func resourceTransitVirtualInterfaceCreate(ctx context.Context, d *schema.Resour conn := meta.(*conns.AWSClient).DirectConnectClient(ctx) req := &directconnect.CreateTransitVirtualInterfaceInput{ - ConnectionId: aws.String(d.Get("connection_id").(string)), + ConnectionId: aws.String(d.Get(names.AttrConnectionID).(string)), NewTransitVirtualInterface: &awstypes.NewTransitVirtualInterface{ AddressFamily: awstypes.AddressFamily(d.Get("address_family").(string)), Asn: int32(d.Get("bgp_asn").(int)), @@ -141,7 +141,7 @@ func resourceTransitVirtualInterfaceCreate(ctx context.Context, d *schema.Resour EnableSiteLink: aws.Bool(d.Get("sitelink_enabled").(bool)), Mtu: aws.Int32(int32(d.Get("mtu").(int))), Tags: getTagsIn(ctx), - VirtualInterfaceName: aws.String(d.Get("name").(string)), + VirtualInterfaceName: aws.String(d.Get(names.AttrName).(string)), Vlan: int32(d.Get("vlan").(int)), }, } @@ -194,16 +194,16 @@ func resourceTransitVirtualInterfaceRead(ctx context.Context, d *schema.Resource AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("dxvif/%s", d.Id()), }.String() - d.Set("arn", arn) + d.Set(names.AttrARN, arn) d.Set("aws_device", vif.AwsDeviceV2) d.Set("bgp_asn", vif.Asn) d.Set("bgp_auth_key", vif.AuthKey) - d.Set("connection_id", vif.ConnectionId) + d.Set(names.AttrConnectionID, vif.ConnectionId) d.Set("customer_address", vif.CustomerAddress) d.Set("dx_gateway_id", vif.DirectConnectGatewayId) d.Set("jumbo_frame_capable", vif.JumboFrameCapable) d.Set("mtu", vif.Mtu) - d.Set("name", vif.VirtualInterfaceName) + d.Set(names.AttrName, vif.VirtualInterfaceName) d.Set("sitelink_enabled", vif.SiteLinkEnabled) d.Set("vlan", vif.Vlan) diff --git a/internal/service/directconnect/transit_virtual_interface_test.go b/internal/service/directconnect/transit_virtual_interface_test.go index fc8535a6249..181822eb54c 100644 --- a/internal/service/directconnect/transit_virtual_interface_test.go +++ b/internal/service/directconnect/transit_virtual_interface_test.go @@ -24,7 +24,7 @@ func TestAccDirectConnectTransitVirtualInterface_serial(t *testing.T) { t.Parallel() testCases := map[string]func(t *testing.T){ - "basic": testAccTransitVirtualInterface_basic, + acctest.CtBasic: testAccTransitVirtualInterface_basic, "tags": testAccTransitVirtualInterface_tags, "sitelink": testAccTransitVirtualInterface_siteLink, } @@ -61,17 +61,17 @@ func testAccTransitVirtualInterface_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), ), }, @@ -82,17 +82,17 @@ func testAccTransitVirtualInterface_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "8500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), ), }, @@ -135,17 +135,17 @@ func testAccTransitVirtualInterface_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "tags.Key1", "Value1"), resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2a"), @@ -159,17 +159,17 @@ func testAccTransitVirtualInterface_tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "1500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "tags.%", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct3), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2b"), resource.TestCheckResourceAttr(resourceName, "tags.Key3", "Value3"), @@ -215,18 +215,18 @@ func testAccTransitVirtualInterface_siteLink(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "8500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", "true"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", acctest.CtTrue), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), ), }, @@ -237,18 +237,18 @@ func testAccTransitVirtualInterface_siteLink(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "address_family", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "amazon_address"), resource.TestCheckResourceAttrSet(resourceName, "amazon_side_asn"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), + acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "directconnect", regexache.MustCompile(fmt.Sprintf("dxvif/%s", aws.ToString(vif.VirtualInterfaceId)))), resource.TestCheckResourceAttrSet(resourceName, "aws_device"), resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(bgpAsn)), resource.TestCheckResourceAttrSet(resourceName, "bgp_auth_key"), - resource.TestCheckResourceAttr(resourceName, "connection_id", connectionId), + resource.TestCheckResourceAttr(resourceName, names.AttrConnectionID, connectionId), resource.TestCheckResourceAttrSet(resourceName, "customer_address"), - resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, "id"), - resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", "true"), + resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", dxGatewayResourceName, names.AttrID), + resource.TestCheckResourceAttr(resourceName, "jumbo_frame_capable", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "mtu", "8500"), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", "false"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), + resource.TestCheckResourceAttr(resourceName, "sitelink_enabled", acctest.CtFalse), + resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0), resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)), ), },