Skip to content

Commit

Permalink
Run 'make fix-constants PKG=ec2'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Jun 28, 2024
1 parent e5a3a8f commit 9ae0b09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func dataSourceTransitGatewayPeeringAttachmentsRead(ctx context.Context, d *sche
}

d.SetId(meta.(*conns.AWSClient).Region)
d.Set("ids", tfslices.ApplyToAll(output, func(v awstypes.TransitGatewayPeeringAttachment) string {
d.Set(names.AttrIDs, tfslices.ApplyToAll(output, func(v awstypes.TransitGatewayPeeringAttachment) string {
return aws.ToString(v.TransitGatewayAttachmentId)
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package ec2_test

import (
"fmt"
"testing"

sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
Expand All @@ -22,69 +21,34 @@ func testAccTransitGatewayPeeringAttachmentsDataSource_Filter(t *testing.T, sema
PreCheck: func() {
testAccPreCheckTransitGatewaySynchronize(t, semaphore)
acctest.PreCheck(ctx, t)
testAccPreCheckTransitGatewayVPCAttachment(ctx, t)
testAccPreCheckTransitGateway(ctx, t)
acctest.PreCheckMultipleRegion(t, 2)
},
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
ProtoV5ProviderFactories: acctest.ProtoV5FactoriesAlternate(ctx, t),
Steps: []resource.TestStep{
{
Config: testAccTransitGatewayPeeringAttachmentsDataSourceConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_ec2_transit_gateway_peering_attachments.by_attachment_id", "ids.#", "1"),
resource.TestCheckResourceAttr("data.aws_ec2_transit_gateway_peering_attachments.by_gateway_id", "ids.#", "2"),
Check: resource.ComposeAggregateTestCheckFunc(
acctest.CheckResourceAttrGreaterThanOrEqualValue("data.aws_ec2_transit_gateway_peering_attachments.all", "ids.#", 1),
resource.TestCheckResourceAttr("data.aws_ec2_transit_gateway_peering_attachments.by_attachment_id", "ids.#", acctest.Ct1),
),
},
},
})
}

func testAccTransitGatewayPeeringAttachmentsDataSourceConfig_basic(rName string) string {
return acctest.ConfigCompose(acctest.ConfigAvailableAZsNoOptInDefaultExclude(), fmt.Sprintf(`
resource "aws_vpc" "test1" {
cidr_block = "10.0.0.0/16"
tags = {
Name = %[1]q
}
}
resource "aws_ec2_transit_gateway" "test1" {
amazon_side_asn = "64512"
tags = {
Name = %[1]q
}
}
resource "aws_ec2_transit_gateway" "test2" {
amazon_side_asn = "64513"
tags = {
Name = %[1]q
}
}
resource "aws_ec2_transit_gateway_peering_attachment" "test1" {
transit_gateway_id = aws_ec2_transit_gateway.test1.id
peer_transit_gateway_id = aws_ec2_transit_gateway.test2.id
tags = {
Name = %[1]q
}
return acctest.ConfigCompose(testAccTransitGatewayPeeringAttachmentConfig_sameAccount(rName), `
data "aws_ec2_transit_gateway_peering_attachments" "all" {
depends_on = [aws_ec2_transit_gateway_peering_attachment.test]
}
data "aws_ec2_transit_gateway_peering_attachments" "by_attachment_id" {
filter {
name = "transit-gateway-attachment-id"
values = [aws_ec2_transit_gateway_peering_attachment.test1.id]
}
}
data "aws_ec2_transit_gateway_peering_attachments" "by_gateway_id" {
filter {
name = "transit-gateway-id"
values = [aws_ec2_transit_gateway.test1.id]
values = [aws_ec2_transit_gateway_peering_attachment.test.id]
}
}
`, rName))
`)
}

0 comments on commit 9ae0b09

Please sign in to comment.