From ee92dc3a83cb4c380d21fa9037db1e7c9ec599bf Mon Sep 17 00:00:00 2001 From: trc-ikeskin Date: Wed, 21 Jun 2023 13:30:00 +0200 Subject: [PATCH 1/6] fix: add missing 'id' values in pool map (#32106) --- internal/service/ec2/ipam_pools_data_source.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/service/ec2/ipam_pools_data_source.go b/internal/service/ec2/ipam_pools_data_source.go index b07ef86efe7..155c58ee357 100644 --- a/internal/service/ec2/ipam_pools_data_source.go +++ b/internal/service/ec2/ipam_pools_data_source.go @@ -25,6 +25,10 @@ func DataSourceIPAMPools() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Optional: true, + }, "address_family": { Type: schema.TypeString, Computed: true, @@ -58,10 +62,6 @@ func DataSourceIPAMPools() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "id": { - Type: schema.TypeString, - Optional: true, - }, "ipam_scope_id": { Type: schema.TypeString, Computed: true, @@ -70,10 +70,6 @@ func DataSourceIPAMPools() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "ipam_pool_id": { - Type: schema.TypeString, - Computed: true, - }, "locale": { Type: schema.TypeString, Computed: true, @@ -140,6 +136,7 @@ func flattenIPAMPools(ctx context.Context, c []*ec2.IpamPool, ignoreTagsConfig * func flattenIPAMPool(ctx context.Context, p *ec2.IpamPool, ignoreTagsConfig *tftags.IgnoreConfig) map[string]interface{} { pool := make(map[string]interface{}) + pool["id"] = aws.StringValue(p.IpamPoolId) pool["address_family"] = aws.StringValue(p.AddressFamily) pool["allocation_default_netmask_length"] = aws.Int64Value(p.AllocationDefaultNetmaskLength) pool["allocation_max_netmask_length"] = aws.Int64Value(p.AllocationMaxNetmaskLength) From eeb1f414d0151c1802e597699135e7548613a28f Mon Sep 17 00:00:00 2001 From: trc-ikeskin Date: Wed, 21 Jun 2023 13:32:37 +0200 Subject: [PATCH 2/6] adding tests for 'id' attribute %make testacc TESTS=TestAccIPAMPoolsDataSource PKG=ec2 ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccIPAMPoolsDataSource' -timeout 180m === RUN TestAccIPAMPoolsDataSource_basic === PAUSE TestAccIPAMPoolsDataSource_basic === RUN TestAccIPAMPoolsDataSource_empty === PAUSE TestAccIPAMPoolsDataSource_empty === CONT TestAccIPAMPoolsDataSource_basic === CONT TestAccIPAMPoolsDataSource_empty --- PASS: TestAccIPAMPoolsDataSource_empty (9.80s) --- PASS: TestAccIPAMPoolsDataSource_basic (79.66s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 88.286s --- internal/service/ec2/ipam_pools_data_source_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/service/ec2/ipam_pools_data_source_test.go b/internal/service/ec2/ipam_pools_data_source_test.go index 2579bef6140..674cae57369 100644 --- a/internal/service/ec2/ipam_pools_data_source_test.go +++ b/internal/service/ec2/ipam_pools_data_source_test.go @@ -33,6 +33,7 @@ func TestAccIPAMPoolsDataSource_basic(t *testing.T) { // DS 2 filters on 1 specific pool to validate attributes resource.TestCheckResourceAttr(dataSourceNameTwo, "ipam_pools.#", "1"), + resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.id", resourceName, "id"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.address_family", resourceName, "address_family"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.allocation_default_netmask_length", resourceName, "allocation_default_netmask_length"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.allocation_max_netmask_length", resourceName, "allocation_max_netmask_length"), From aed1c27f55d069c3a1c39d6f1964217265e73585 Mon Sep 17 00:00:00 2001 From: trc-ikeskin Date: Wed, 21 Jun 2023 13:54:10 +0200 Subject: [PATCH 3/6] docs: add changelog entry for PR #32133 --- .changelog/32133.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/32133.txt diff --git a/.changelog/32133.txt b/.changelog/32133.txt new file mode 100644 index 00000000000..f5f025e5379 --- /dev/null +++ b/.changelog/32133.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_vpc_ipam_pools: Fix missing 'id' attributes for individual IPAM pools +``` \ No newline at end of file From 761d9ad6a18cf184d311a8ccc1b4afcc63e0d700 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 30 Oct 2023 11:27:25 -0400 Subject: [PATCH 4/6] Update .changelog/32133.txt Co-authored-by: drewmullen --- .changelog/32133.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/32133.txt b/.changelog/32133.txt index f5f025e5379..1f9e594da3f 100644 --- a/.changelog/32133.txt +++ b/.changelog/32133.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_vpc_ipam_pools: Fix missing 'id' attributes for individual IPAM pools +data_source/aws_vpc_ipam_pools: Fix missing 'id' attributes for individual IPAM pools ``` \ No newline at end of file From 2c2ad01f02805abd3e4506c3f0210cd411e7fd28 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 30 Oct 2023 11:27:54 -0400 Subject: [PATCH 5/6] Update 32133.txt --- .changelog/32133.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changelog/32133.txt b/.changelog/32133.txt index 1f9e594da3f..1c1338904ea 100644 --- a/.changelog/32133.txt +++ b/.changelog/32133.txt @@ -1,3 +1,3 @@ ```release-note:bug -data_source/aws_vpc_ipam_pools: Fix missing 'id' attributes for individual IPAM pools -``` \ No newline at end of file +data_source/aws_vpc_ipam_pools: Add `id` attribute for individual IPAM pools +``` From b7e8d14082f507a39021465ab1df4bed908e4317 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 30 Oct 2023 11:32:28 -0400 Subject: [PATCH 6/6] d/aws_vpc_ipam_pools: ipam_pools.id is Computed. --- internal/service/ec2/ipam_pools_data_source.go | 11 +++++------ internal/service/ec2/ipam_pools_data_source_test.go | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/service/ec2/ipam_pools_data_source.go b/internal/service/ec2/ipam_pools_data_source.go index 3548b074f08..18e0c52a513 100644 --- a/internal/service/ec2/ipam_pools_data_source.go +++ b/internal/service/ec2/ipam_pools_data_source.go @@ -28,10 +28,6 @@ func DataSourceIPAMPools() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Optional: true, - }, "address_family": { Type: schema.TypeString, Computed: true, @@ -65,6 +61,10 @@ func DataSourceIPAMPools() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "id": { + Type: schema.TypeString, + Computed: true, + }, "ipam_scope_id": { Type: schema.TypeString, Computed: true, @@ -139,7 +139,6 @@ func flattenIPAMPools(ctx context.Context, c []*ec2.IpamPool, ignoreTagsConfig * func flattenIPAMPool(ctx context.Context, p *ec2.IpamPool, ignoreTagsConfig *tftags.IgnoreConfig) map[string]interface{} { pool := make(map[string]interface{}) - pool["id"] = aws.StringValue(p.IpamPoolId) pool["address_family"] = aws.StringValue(p.AddressFamily) pool["allocation_default_netmask_length"] = aws.Int64Value(p.AllocationDefaultNetmaskLength) pool["allocation_max_netmask_length"] = aws.Int64Value(p.AllocationMaxNetmaskLength) @@ -149,6 +148,7 @@ func flattenIPAMPool(ctx context.Context, p *ec2.IpamPool, ignoreTagsConfig *tft pool["auto_import"] = aws.BoolValue(p.AutoImport) pool["aws_service"] = aws.StringValue(p.AwsService) pool["description"] = aws.StringValue(p.Description) + pool["id"] = aws.StringValue(p.IpamPoolId) pool["ipam_scope_id"] = strings.Split(aws.StringValue(p.IpamScopeArn), "/")[1] pool["ipam_scope_type"] = aws.StringValue(p.IpamScopeType) pool["locale"] = aws.StringValue(p.Locale) @@ -156,7 +156,6 @@ func flattenIPAMPool(ctx context.Context, p *ec2.IpamPool, ignoreTagsConfig *tft pool["publicly_advertisable"] = aws.BoolValue(p.PubliclyAdvertisable) pool["source_ipam_pool_id"] = aws.StringValue(p.SourceIpamPoolId) pool["state"] = aws.StringValue(p.State) - if v := p.Tags; v != nil { pool["tags"] = KeyValueTags(ctx, v).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map() } diff --git a/internal/service/ec2/ipam_pools_data_source_test.go b/internal/service/ec2/ipam_pools_data_source_test.go index e018b48565b..322633d7fed 100644 --- a/internal/service/ec2/ipam_pools_data_source_test.go +++ b/internal/service/ec2/ipam_pools_data_source_test.go @@ -36,7 +36,6 @@ func TestAccIPAMPoolsDataSource_basic(t *testing.T) { // DS 2 filters on 1 specific pool to validate attributes resource.TestCheckResourceAttr(dataSourceNameTwo, "ipam_pools.#", "1"), - resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.id", resourceName, "id"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.address_family", resourceName, "address_family"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.allocation_default_netmask_length", resourceName, "allocation_default_netmask_length"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.allocation_max_netmask_length", resourceName, "allocation_max_netmask_length"), @@ -46,6 +45,7 @@ func TestAccIPAMPoolsDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.auto_import", resourceName, "auto_import"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.description", resourceName, "description"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.aws_service", resourceName, "aws_service"), + resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.id", resourceName, "id"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.ipam_scope_id", resourceName, "ipam_scope_id"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.ipam_scope_type", resourceName, "ipam_scope_type"), resource.TestCheckResourceAttrPair(dataSourceNameTwo, "ipam_pools.0.locale", resourceName, "locale"),