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

Add enable_network_address_usage_metrics to VPC #27165

Merged

Conversation

bschaatsbergen
Copy link
Member

@bschaatsbergen bschaatsbergen commented Oct 8, 2022

Description

Adding a new enable_network_address_usage_metrics attribute to aws_vpc and aws_default_vpc.

Relations

Closes #27139

References

Output from Acceptance Testing

$ make testacc TESTS=TestAccVPC_basic\|TestAccVPC_enableNetworkAddressUsageMetrics\|TestAccVPCDataSource_basic\|TestAccEC2DefaultVPC_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPC_basic|TestAccVPC_enableNetworkAddressUsageMetrics|TestAccVPCDataSource_basic|TestAccEC2DefaultVPC_'  -timeout 180m
=== RUN   TestAccVPCDataSource_basic
=== PAUSE TestAccVPCDataSource_basic
=== RUN   TestAccVPC_basic
=== PAUSE TestAccVPC_basic
=== RUN   TestAccVPC_enableNetworkAddressUsageMetrics
=== PAUSE TestAccVPC_enableNetworkAddressUsageMetrics
=== CONT  TestAccVPCDataSource_basic
=== CONT  TestAccVPC_enableNetworkAddressUsageMetrics
=== CONT  TestAccVPC_basic
--- PASS: TestAccVPC_basic (31.13s)
--- PASS: TestAccVPC_enableNetworkAddressUsageMetrics (42.43s)
--- PASS: TestAccVPCDataSource_basic (42.91s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        44.660s

@github-actions
Copy link

github-actions bot commented Oct 8, 2022

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 size/M Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. service/vpc Issues and PRs that pertain to the vpc service. labels Oct 8, 2022
@bschaatsbergen bschaatsbergen marked this pull request as ready for review October 8, 2022 23:29
@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Oct 8, 2022
@bschaatsbergen bschaatsbergen marked this pull request as draft October 8, 2022 23:33
@github-actions github-actions bot added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Oct 8, 2022
@bschaatsbergen bschaatsbergen changed the title Add enable_network_address_usage_metrics to VPC Add enable_network_address_usage_metrics to VPC resources/data source. Oct 8, 2022
@bschaatsbergen bschaatsbergen changed the title Add enable_network_address_usage_metrics to VPC resources/data source. Add enable_network_address_usage_metrics to VPC Oct 8, 2022
@bschaatsbergen bschaatsbergen marked this pull request as ready for review October 9, 2022 00:10
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Oct 10, 2022
@github-actions github-actions bot removed the size/M Managed by automation to categorize the size of a PR. label Oct 10, 2022
@github-actions github-actions bot added the size/L Managed by automation to categorize the size of a PR. label Oct 10, 2022
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

AWS Commercial
% make testacc TESTARGS='-run=TestAccVPCDataSource_\|TestAccVPC_\|TestAccVPCDefaultVPCAndSubnet_serial/VPC' PKG=ec2 ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 2  -run=TestAccVPCDataSource_\|TestAccVPC_\|TestAccVPCDefaultVPCAndSubnet_serial/VPC -timeout 180m
=== RUN   TestAccVPCDataSource_basic
=== PAUSE TestAccVPCDataSource_basic
=== RUN   TestAccVPCDataSource_CIDRBlockAssociations_multiple
=== PAUSE TestAccVPCDataSource_CIDRBlockAssociations_multiple
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.forceDestroy
    acctest.go:704: skipping tests; AWS_DEFAULT_REGION (us-west-2) not supported
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.basic
    acctest.go:704: skipping tests; AWS_DEFAULT_REGION (us-west-2) not supported
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.assignGeneratedIPv6CIDRBlock
    acctest.go:704: skipping tests; AWS_DEFAULT_REGION (us-west-2) not supported
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.forceDestroy
    acctest.go:704: skipping tests; AWS_DEFAULT_REGION (us-west-2) not supported
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.basic
    acctest.go:704: skipping tests; AWS_DEFAULT_REGION (us-west-2) not supported
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.assignGeneratedIPv6CIDRBlock
    acctest.go:704: skipping tests; AWS_DEFAULT_REGION (us-west-2) not supported
--- PASS: TestAccVPCDefaultVPCAndSubnet_serial (1.04s)
    --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC (1.04s)
        --- SKIP: TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.forceDestroy (1.04s)
        --- SKIP: TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.basic (0.00s)
        --- SKIP: TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.assignGeneratedIPv6CIDRBlock (0.00s)
        --- SKIP: TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.forceDestroy (0.00s)
        --- SKIP: TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.basic (0.00s)
        --- SKIP: TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.assignGeneratedIPv6CIDRBlock (0.00s)
=== RUN   TestAccVPC_basic
=== PAUSE TestAccVPC_basic
=== RUN   TestAccVPC_disappears
=== PAUSE TestAccVPC_disappears
=== RUN   TestAccVPC_tags
=== PAUSE TestAccVPC_tags
=== RUN   TestAccVPC_DefaultTags_providerOnly
=== PAUSE TestAccVPC_DefaultTags_providerOnly
=== RUN   TestAccVPC_DefaultTags_updateToProviderOnly
=== PAUSE TestAccVPC_DefaultTags_updateToProviderOnly
=== RUN   TestAccVPC_DefaultTags_updateToResourceOnly
=== PAUSE TestAccVPC_DefaultTags_updateToResourceOnly
=== RUN   TestAccVPC_DefaultTagsProviderAndResource_nonOverlappingTag
=== PAUSE TestAccVPC_DefaultTagsProviderAndResource_nonOverlappingTag
=== RUN   TestAccVPC_DefaultTagsProviderAndResource_overlappingTag
=== PAUSE TestAccVPC_DefaultTagsProviderAndResource_overlappingTag
=== RUN   TestAccVPC_DefaultTagsProviderAndResource_duplicateTag
=== PAUSE TestAccVPC_DefaultTagsProviderAndResource_duplicateTag
=== RUN   TestAccVPC_DynamicResourceTagsMergedWithLocals_ignoreChanges
=== PAUSE TestAccVPC_DynamicResourceTagsMergedWithLocals_ignoreChanges
=== RUN   TestAccVPC_DynamicResourceTags_ignoreChanges
=== PAUSE TestAccVPC_DynamicResourceTags_ignoreChanges
=== RUN   TestAccVPC_defaultAndIgnoreTags
=== PAUSE TestAccVPC_defaultAndIgnoreTags
=== RUN   TestAccVPC_ignoreTags
=== PAUSE TestAccVPC_ignoreTags
=== RUN   TestAccVPC_tenancy
=== PAUSE TestAccVPC_tenancy
=== RUN   TestAccVPC_updateDNSHostnames
=== PAUSE TestAccVPC_updateDNSHostnames
=== RUN   TestAccVPC_bothDNSOptionsSet
=== PAUSE TestAccVPC_bothDNSOptionsSet
=== RUN   TestAccVPC_disabledDNSSupport
=== PAUSE TestAccVPC_disabledDNSSupport
=== RUN   TestAccVPC_enableNetworkAddressUsageMetrics
=== PAUSE TestAccVPC_enableNetworkAddressUsageMetrics
=== RUN   TestAccVPC_assignGeneratedIPv6CIDRBlock
=== PAUSE TestAccVPC_assignGeneratedIPv6CIDRBlock
=== RUN   TestAccVPC_assignGeneratedIPv6CIDRBlockWithNetworkBorderGroup
=== PAUSE TestAccVPC_assignGeneratedIPv6CIDRBlockWithNetworkBorderGroup
=== RUN   TestAccVPC_IPAMIPv4BasicNetmask
=== PAUSE TestAccVPC_IPAMIPv4BasicNetmask
=== RUN   TestAccVPC_IPAMIPv4BasicExplicitCIDR
=== PAUSE TestAccVPC_IPAMIPv4BasicExplicitCIDR
=== CONT  TestAccVPCDataSource_basic
=== CONT  TestAccVPC_DynamicResourceTags_ignoreChanges
--- PASS: TestAccVPCDataSource_basic (33.12s)
=== CONT  TestAccVPC_disabledDNSSupport
--- PASS: TestAccVPC_DynamicResourceTags_ignoreChanges (34.97s)
=== CONT  TestAccVPC_IPAMIPv4BasicExplicitCIDR
--- PASS: TestAccVPC_disabledDNSSupport (31.45s)
=== CONT  TestAccVPC_IPAMIPv4BasicNetmask
--- PASS: TestAccVPC_IPAMIPv4BasicExplicitCIDR (1720.37s)
=== CONT  TestAccVPC_assignGeneratedIPv6CIDRBlockWithNetworkBorderGroup
    vpc_test.go:796: Step 1/3 error: Error running apply: exit status 1
        
        Error: error creating EC2 VPC: InvalidParameterValue: us-west-2-las-1
        	status code: 400, request id: 336e0e7c-7204-4e66-83b7-b2f5e41ad32c
        
          with aws_vpc.test,
          on terraform_plugin_test.tf line 22, in resource "aws_vpc" "test":
          22: resource "aws_vpc" "test" {
        
--- FAIL: TestAccVPC_assignGeneratedIPv6CIDRBlockWithNetworkBorderGroup (7.72s)
=== CONT  TestAccVPC_assignGeneratedIPv6CIDRBlock
--- PASS: TestAccVPC_IPAMIPv4BasicNetmask (1749.97s)
=== CONT  TestAccVPC_enableNetworkAddressUsageMetrics
--- PASS: TestAccVPC_enableNetworkAddressUsageMetrics (32.42s)
=== CONT  TestAccVPC_DefaultTags_updateToProviderOnly
--- PASS: TestAccVPC_assignGeneratedIPv6CIDRBlock (84.94s)
=== CONT  TestAccVPC_DynamicResourceTagsMergedWithLocals_ignoreChanges
--- PASS: TestAccVPC_DefaultTags_updateToProviderOnly (29.35s)
=== CONT  TestAccVPC_DefaultTagsProviderAndResource_duplicateTag
--- PASS: TestAccVPC_DefaultTagsProviderAndResource_duplicateTag (1.48s)
=== CONT  TestAccVPC_DefaultTagsProviderAndResource_overlappingTag
--- PASS: TestAccVPC_DynamicResourceTagsMergedWithLocals_ignoreChanges (33.92s)
=== CONT  TestAccVPC_DefaultTagsProviderAndResource_nonOverlappingTag
--- PASS: TestAccVPC_DefaultTagsProviderAndResource_overlappingTag (43.02s)
=== CONT  TestAccVPC_DefaultTags_updateToResourceOnly
--- PASS: TestAccVPC_DefaultTagsProviderAndResource_nonOverlappingTag (43.94s)
=== CONT  TestAccVPC_ignoreTags
--- PASS: TestAccVPC_DefaultTags_updateToResourceOnly (31.29s)
=== CONT  TestAccVPC_disappears
--- PASS: TestAccVPC_ignoreTags (39.16s)
=== CONT  TestAccVPC_DefaultTags_providerOnly
--- PASS: TestAccVPC_disappears (15.08s)
=== CONT  TestAccVPC_tags
--- PASS: TestAccVPC_DefaultTags_providerOnly (43.21s)
=== CONT  TestAccVPC_bothDNSOptionsSet
--- PASS: TestAccVPC_tags (54.32s)
=== CONT  TestAccVPC_basic
--- PASS: TestAccVPC_bothDNSOptionsSet (32.36s)
=== CONT  TestAccVPC_updateDNSHostnames
--- PASS: TestAccVPC_basic (21.97s)
=== CONT  TestAccVPC_tenancy
--- PASS: TestAccVPC_updateDNSHostnames (43.90s)
=== CONT  TestAccVPCDataSource_CIDRBlockAssociations_multiple
--- PASS: TestAccVPC_tenancy (62.05s)
=== CONT  TestAccVPC_defaultAndIgnoreTags
--- PASS: TestAccVPCDataSource_CIDRBlockAssociations_multiple (43.39s)
--- PASS: TestAccVPC_defaultAndIgnoreTags (39.55s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	2150.287s
FAIL
make: *** [testacc] Error 1
% AWS_DEFAULT_REGION=eu-west-1 make testacc TESTARGS='-run=TestAccVPCDefaultVPCAndSubnet_serial/VPC' PKG=ec2                       
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccVPCDefaultVPCAndSubnet_serial/VPC -timeout 180m
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.basic
    vpc_default_vpc_test.go:61: Deleting existing default VPC: vpc-5ed6853b
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.assignGeneratedIPv6CIDRBlock
    vpc_default_vpc_test.go:61: Deleting existing default VPC: vpc-0d541d0df56b63b0d
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.forceDestroy
    vpc_default_vpc_test.go:61: Deleting existing default VPC: vpc-0a87599bcc87c3070
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.basic
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.assignGeneratedIPv6CIDRBlock
=== RUN   TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.forceDestroy
--- PASS: TestAccVPCDefaultVPCAndSubnet_serial (227.60s)
    --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC (227.60s)
        --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.basic (35.04s)
        --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.assignGeneratedIPv6CIDRBlock (46.23s)
        --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC/notFound.forceDestroy (41.80s)
        --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.basic (30.30s)
        --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.assignGeneratedIPv6CIDRBlock (29.51s)
        --- PASS: TestAccVPCDefaultVPCAndSubnet_serial/VPC/existing.forceDestroy (44.71s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	231.649s

Failure is unrelated to this change.

AWS US GovCloud
% make testacc TESTARGS='-run=TestAccVPC_basic\|TestAccVPC_enableNetworkAddressUsageMetrics' PKG=ec2 ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 2  -run=TestAccVPC_basic\|TestAccVPC_enableNetworkAddressUsageMetrics -timeout 180m
=== RUN   TestAccVPC_basic
=== PAUSE TestAccVPC_basic
=== RUN   TestAccVPC_enableNetworkAddressUsageMetrics
=== PAUSE TestAccVPC_enableNetworkAddressUsageMetrics
=== CONT  TestAccVPC_basic
=== CONT  TestAccVPC_enableNetworkAddressUsageMetrics
    acctest.go:727: skipping tests; current partition (aws-us-gov) not supported
--- SKIP: TestAccVPC_enableNetworkAddressUsageMetrics (1.08s)
--- PASS: TestAccVPC_basic (29.67s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	35.801s

@ewbankkit
Copy link
Contributor

@bschaatsbergen Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 19574e3 into hashicorp:main Oct 10, 2022
@github-actions github-actions bot added this to the v4.35.0 milestone Oct 10, 2022
@bschaatsbergen bschaatsbergen deleted the add-enableNetworkAddressUsageMetrics branch October 10, 2022 15:19
@github-actions
Copy link

This functionality has been released in v4.35.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!

@lorengordon
Copy link
Contributor

@ewbankkit @bschaatsbergen This PR breaks aws_default_vpc in GovCloud regions, because it attempts to set enable_network_address_usage_metrics to true...

Minimal reproducing config:

resource "aws_default_vpc" "default" {}

Proof I'm in GovCloud, note the partition in the ARN:

❯ aws sts get-caller-identity
{
    "UserId": "AROALredacted:botocore-session-1668623771",
    "Account": "redacted",
    "Arn": "arn:aws-us-gov:sts::redacted:assumed-role/redacted/botocore-session-1668623771"
}

Proof it is attempting to set enable_network_address_usage_metrics = true:

❯ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_default_vpc.default will be created
  + resource "aws_default_vpc" "default" {
      + arn                                  = (known after apply)
      + cidr_block                           = (known after apply)
      + default_network_acl_id               = (known after apply)
      + default_route_table_id               = (known after apply)
      + default_security_group_id            = (known after apply)
      + dhcp_options_id                      = (known after apply)
      + enable_classiclink                   = (known after apply)
      + enable_classiclink_dns_support       = (known after apply)
      + enable_dns_hostnames                 = true
      + enable_dns_support                   = true
      + enable_network_address_usage_metrics = true
      + existing_default_vpc                 = (known after apply)
      + force_destroy                        = false
      + id                                   = (known after apply)
      + instance_tenancy                     = (known after apply)
      + ipv6_association_id                  = (known after apply)
      + ipv6_cidr_block                      = (known after apply)
      + ipv6_cidr_block_network_border_group = (known after apply)
      + main_route_table_id                  = (known after apply)
      + owner_id                             = (known after apply)
      + tags_all                             = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_default_vpc.default: Creating...
aws_default_vpc.default: Still creating... [10s elapsed]
aws_default_vpc.default: Still creating... [20s elapsed]
aws_default_vpc.default: Still creating... [30s elapsed]
aws_default_vpc.default: Still creating... [40s elapsed]
aws_default_vpc.default: Still creating... [50s elapsed]
aws_default_vpc.default: Still creating... [1m0s elapsed]
aws_default_vpc.default: Still creating... [1m10s elapsed]
aws_default_vpc.default: Still creating... [1m20s elapsed]
aws_default_vpc.default: Still creating... [1m30s elapsed]
aws_default_vpc.default: Still creating... [1m40s elapsed]
aws_default_vpc.default: Still creating... [1m50s elapsed]
aws_default_vpc.default: Still creating... [2m0s elapsed]
aws_default_vpc.default: Still creating... [2m10s elapsed]
aws_default_vpc.default: Still creating... [2m20s elapsed]
aws_default_vpc.default: Still creating... [2m30s elapsed]
aws_default_vpc.default: Still creating... [2m40s elapsed]
aws_default_vpc.default: Still creating... [2m50s elapsed]
aws_default_vpc.default: Still creating... [3m0s elapsed]
aws_default_vpc.default: Still creating... [3m10s elapsed]
aws_default_vpc.default: Still creating... [3m20s elapsed]
aws_default_vpc.default: Still creating... [3m30s elapsed]
aws_default_vpc.default: Still creating... [3m40s elapsed]
aws_default_vpc.default: Still creating... [3m50s elapsed]
aws_default_vpc.default: Still creating... [4m0s elapsed]
aws_default_vpc.default: Still creating... [4m10s elapsed]
aws_default_vpc.default: Still creating... [4m20s elapsed]
aws_default_vpc.default: Still creating... [4m30s elapsed]
aws_default_vpc.default: Still creating... [4m40s elapsed]
aws_default_vpc.default: Still creating... [4m50s elapsed]
aws_default_vpc.default: Still creating... [5m0s elapsed]
╷
│ Error: error waiting for EC2 VPC (vpc-redacted) EnableNetworkAddressUsageMetrics update: timeout while waiting for state to become 'true' (last state: 'false', timeout: 5m0s)
│
│   with aws_default_vpc.default,
│   on main.tf line 1, in resource "aws_default_vpc" "default":
│    1: resource "aws_default_vpc" "default" {}

@github-actions
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 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. service/vpc Issues and PRs that pertain to the vpc service. size/L Managed by automation to categorize the size of a PR. 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.

[Enhancement]: Support enabling NAU metrics in "aws_vpc" resource
3 participants