Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

d/aws_subnet: use Tags field from DescribeSubnets response #40144

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Nov 15, 2024

Description

This change modifies the transparent tagging configuration for this data source to use the Tags field from the DescribeSubnets response, rather than making an additional call to the DescribeTags API. As a side effect, this data source will no longer require the calling principal to have the ec2:DescribeTags IAM permission, fixing a regression introduced in v5.73.0.


As additional confirmation that this change no longer results in calls to the DescribeTags API I created a simple configuration with the following subnet data source.

data "aws_subnet" "by_id" {
  id = aws_subnet.test.id
}

After the initial infrastructure is provisioned, this data source is read on every plan operation. By searching the debug logs for a plan operation with v5.76.0 (latest release) and a build from this release branch, it can be confirmed that the data source is no longer making the additional API call.

v5.76.0:

% TF_LOG=debug terraform plan &> plan-old.out
% rg "Action\=DescribeTags" plan-old.out
514:  | Action=DescribeTags&Filter.1.Name=resource-id&Filter.1.Value.1=subnet-0ae0a93e8c9560290&Version=2016-11-15

This branch:

% TF_LOG=debug TF_CLI_CONFIG_FILE=dev.tfrc terraform plan &> plan.out
% rg "Action\=DescribeTags" plan.out
(no results)

Relations

Closes #40104

Output from Acceptance Testing

% make testacc PKG=ec2 TESTS=TestAccVPCSubnetDataSource_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSubnetDataSource_'  -timeout 360m
2024/11/15 10:06:55 Initializing Terraform AWS Provider...

=== NAME  TestAccVPCSubnetDataSource_enableLniAtDeviceIndex
    vpc_subnet_data_source_test.go:197: skipping since no Outposts found
--- SKIP: TestAccVPCSubnetDataSource_enableLniAtDeviceIndex (0.79s)
--- PASS: TestAccVPCSubnetDataSource_tags_EmptyMap (19.23s)
--- PASS: TestAccVPCSubnetDataSource_tags (19.64s)
--- PASS: TestAccVPCSubnetDataSource_tags_NullMap (19.64s)
--- PASS: TestAccVPCSubnetDataSource_tags_IgnoreTags_Overlap_DefaultTag (19.73s)
--- PASS: TestAccVPCSubnetDataSource_tags_DefaultTags_nonOverlapping (19.74s)
--- PASS: TestAccVPCSubnetDataSource_basic (20.45s)
--- PASS: TestAccVPCSubnetDataSource_tags_IgnoreTags_Overlap_ResourceTag (20.92s)
--- PASS: TestAccVPCSubnetDataSource_ipv6ByIPv6CIDRBlock (36.98s)
--- PASS: TestAccVPCSubnetDataSource_ipv6ByIPv6Filter (37.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        42.238s

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. generators Relates to code generators. service/vpc Issues and PRs that pertain to the vpc service. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. labels Nov 15, 2024
This change modifies the transparent tagging configuration for this data source to use the `Tags` field from the `DescribeSubnets` response, rather than making an additional call to the `DescribeTags` API. As a side effect, this data source will no longer require the calling principal to have the `ec2:DescribeTags` IAM permission, fixing a regression introduced in `v5.73.0`.

```console
% make testacc PKG=ec2 TESTS=TestAccVPCSubnetDataSource_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSubnetDataSource_'  -timeout 360m
2024/11/15 10:06:55 Initializing Terraform AWS Provider...

=== NAME  TestAccVPCSubnetDataSource_enableLniAtDeviceIndex
    vpc_subnet_data_source_test.go:197: skipping since no Outposts found
--- SKIP: TestAccVPCSubnetDataSource_enableLniAtDeviceIndex (0.79s)
--- PASS: TestAccVPCSubnetDataSource_tags_EmptyMap (19.23s)
--- PASS: TestAccVPCSubnetDataSource_tags (19.64s)
--- PASS: TestAccVPCSubnetDataSource_tags_NullMap (19.64s)
--- PASS: TestAccVPCSubnetDataSource_tags_IgnoreTags_Overlap_DefaultTag (19.73s)
--- PASS: TestAccVPCSubnetDataSource_tags_DefaultTags_nonOverlapping (19.74s)
--- PASS: TestAccVPCSubnetDataSource_basic (20.45s)
--- PASS: TestAccVPCSubnetDataSource_tags_IgnoreTags_Overlap_ResourceTag (20.92s)
--- PASS: TestAccVPCSubnetDataSource_ipv6ByIPv6CIDRBlock (36.98s)
--- PASS: TestAccVPCSubnetDataSource_ipv6ByIPv6Filter (37.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        42.238s
```
@jar-b jar-b force-pushed the b-aws_subnet-ds-tags branch from f23f853 to e5db616 Compare November 15, 2024 15:18
@jar-b jar-b marked this pull request as ready for review November 15, 2024 16:05
@jar-b jar-b requested a review from a team as a code owner November 15, 2024 16:05
Copy link
Contributor

@johnsonaj johnsonaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@jar-b jar-b merged commit 01282ee into main Nov 18, 2024
53 checks passed
@jar-b jar-b deleted the b-aws_subnet-ds-tags branch November 18, 2024 21:02
@github-actions github-actions bot added this to the v5.77.0 milestone Nov 18, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Nov 18, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 21, 2024
Copy link

This functionality has been released in v5.77.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
generators Relates to code generators. service/vpc Issues and PRs that pertain to the vpc service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Release of 5.73.0 leading to change in required IAM permission
2 participants