Skip to content

Commit

Permalink
Run 'make fix-constants PKG=directconnect'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Aug 1, 2024
1 parent cc368ee commit a3116df
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 258 deletions.
14 changes: 7 additions & 7 deletions internal/service/directconnect/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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),
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions internal/service/directconnect/gateway_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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
Expand Down Expand Up @@ -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
}
32 changes: 16 additions & 16 deletions internal/service/directconnect/hosted_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ResourceHostedConnection() *schema.Resource {
ForceNew: true,
ValidateFunc: validConnectionBandWidth(),
},
"connection_id": {
names.AttrConnectionID: {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Expand All @@ -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,
Expand All @@ -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,
},
Expand All @@ -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)),
}

Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions internal/service/directconnect/hosted_private_virtual_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ResourceHostedPrivateVirtualInterface() *schema.Resource {
Computed: true,
ForceNew: true,
},
"arn": {
names.AttrARN: {
Type: schema.TypeString,
Computed: true,
},
Expand All @@ -69,7 +69,7 @@ func ResourceHostedPrivateVirtualInterface() *schema.Resource {
Computed: true,
ForceNew: true,
},
"connection_id": {
names.AttrConnectionID: {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Expand All @@ -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,
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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),
),
},
{
Expand All @@ -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),
),
},
},
Expand Down
Loading

0 comments on commit a3116df

Please sign in to comment.