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

AWS IPAM Multi-Org ResourceDiscovery & ResourceDiscoveryAssociation #29216

Merged
merged 31 commits into from
Feb 16, 2023

Conversation

drewmullen
Copy link
Collaborator

@drewmullen drewmullen commented Feb 2, 2023

Description

Add new IPAM Multi-organizational resource types and features:

  • new resource: resource discovery
  • new resource: resource discovery association
  • new attributes: ipam default_resource_discovery_id && default_resource_discovery_association_id
  • new sweeper: add sweeper that removes all non-default resource discoveries and associations

Relations

Closes #29116

References

Output from Acceptance Testing

$ make testacc TESTS=TestAccIPAMResourceDiscovery_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccIPAMResourceDiscovery_'  -timeout 180m
=== RUN   TestAccIPAMResourceDiscovery_basic
=== PAUSE TestAccIPAMResourceDiscovery_basic
=== RUN   TestAccIPAMResourceDiscovery_modify
=== PAUSE TestAccIPAMResourceDiscovery_modify
=== RUN   TestAccIPAMResourceDiscovery_disappears
=== PAUSE TestAccIPAMResourceDiscovery_disappears
=== RUN   TestAccIPAMResourceDiscovery_tags
=== PAUSE TestAccIPAMResourceDiscovery_tags
=== CONT  TestAccIPAMResourceDiscovery_basic
=== CONT  TestAccIPAMResourceDiscovery_disappears
=== CONT  TestAccIPAMResourceDiscovery_modify
=== CONT  TestAccIPAMResourceDiscovery_tags
--- PASS: TestAccIPAMResourceDiscovery_disappears (24.35s)
--- PASS: TestAccIPAMResourceDiscovery_basic (26.70s)
--- PASS: TestAccIPAMResourceDiscovery_tags (44.87s)
--- PASS: TestAccIPAMResourceDiscovery_modify (84.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        84.112s

$ make testacc TESTS=TestAccIPAMResourceDiscoveryAssociation_ PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccIPAMResourceDiscoveryAssociation_'  -timeout 180m
=== RUN   TestAccIPAMResourceDiscoveryAssociation_basic
=== PAUSE TestAccIPAMResourceDiscoveryAssociation_basic
=== RUN   TestAccIPAMResourceDiscoveryAssociation_tags
=== PAUSE TestAccIPAMResourceDiscoveryAssociation_tags
=== RUN   TestAccIPAMResourceDiscoveryAssociation_disappears
=== PAUSE TestAccIPAMResourceDiscoveryAssociation_disappears
=== CONT  TestAccIPAMResourceDiscoveryAssociation_basic
=== CONT  TestAccIPAMResourceDiscoveryAssociation_disappears
=== CONT  TestAccIPAMResourceDiscoveryAssociation_tags
--- PASS: TestAccIPAMResourceDiscoveryAssociation_basic (37.96s)
--- PASS: TestAccIPAMResourceDiscoveryAssociation_disappears (38.71s)
--- PASS: TestAccIPAMResourceDiscoveryAssociation_tags (57.34s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        57.446s

$ make testacc TESTS=TestAccIPAM_ PKG=ec2                   
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccIPAM_'  -timeout 180m
=== RUN   TestAccIPAM_byoipIPv6
    ipam_byoip_test.go:22: Environment variable IPAM_BYOIP_IPV6_MESSAGE, IPAM_BYOIP_IPV6_SIGNATURE, or IPAM_BYOIP_IPV6_PROVISIONED_CIDR is not set
--- SKIP: TestAccIPAM_byoipIPv6 (0.00s)
=== RUN   TestAccIPAM_basic
=== PAUSE TestAccIPAM_basic
=== RUN   TestAccIPAM_disappears
=== PAUSE TestAccIPAM_disappears
=== RUN   TestAccIPAM_description
=== PAUSE TestAccIPAM_description
=== RUN   TestAccIPAM_operatingRegions
=== PAUSE TestAccIPAM_operatingRegions
=== RUN   TestAccIPAM_cascade
=== PAUSE TestAccIPAM_cascade
=== RUN   TestAccIPAM_tags
=== PAUSE TestAccIPAM_tags
=== CONT  TestAccIPAM_basic
=== CONT  TestAccIPAM_operatingRegions
=== CONT  TestAccIPAM_tags
=== CONT  TestAccIPAM_description
=== CONT  TestAccIPAM_cascade
=== CONT  TestAccIPAM_disappears
--- PASS: TestAccIPAM_disappears (26.89s)
--- PASS: TestAccIPAM_description (45.25s)
--- PASS: TestAccIPAM_tags (49.09s)
--- PASS: TestAccIPAM_basic (52.53s)
--- PASS: TestAccIPAM_cascade (73.24s)
--- PASS: TestAccIPAM_operatingRegions (85.92s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        86.041s

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

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 documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/ipam Issues and PRs that pertain to the ipam service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. size/XL Managed by automation to categorize the size of a PR. labels Feb 2, 2023
@drewmullen drewmullen removed the needs-triage Waiting for first response or review from a maintainer. label Feb 2, 2023
@github-actions github-actions bot added sweeper Pertains to changes to or issues with the sweeper. and removed sweeper Pertains to changes to or issues with the sweeper. labels Feb 2, 2023
@drewmullen
Copy link
Collaborator Author

sweepers working:

  1. build a resource discovery
  2. attach to an ipam
  3. build another resource discovery
  4. run sweepers

youll end up with no associations, and only the default resource discovery:

$ SWEEPARGS=-sweep-run=aws_vpc_ipam_resource_discovery make sweep
# make sweep SWEEPARGS=-sweep-run=aws_example_thing
# set SWEEPARGS=-sweep-allow-failures to continue after first failure
WARNING: This will destroy infrastructure. Use only in development accounts.
go test ./internal/sweep -v -tags=sweep -sweep=us-west-2,us-east-1,us-east-2 -sweep-run=aws_vpc_ipam_resource_discovery -timeout 60m
2023/02/02 14:31:26 [DEBUG] Running Sweepers for region (us-west-2):
2023/02/02 14:31:26 [DEBUG] Running Sweeper (aws_vpc_ipam_resource_discovery) in region (us-west-2)
2023/02/02 14:31:26 [INFO] Retrieved credentials from "EnvConfigCredentials"
2023/02/02 14:31:26 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2023/02/02 14:31:27 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2023/02/02 14:31:27 [DEBUG] Completed Sweeper (aws_vpc_ipam_resource_discovery) in region (us-west-2) in 672.158886ms
2023/02/02 14:31:27 Completed Sweepers for region (us-west-2) in 672.218998ms
2023/02/02 14:31:27 Sweeper Tests for region (us-west-2) ran successfully:
        - aws_vpc_ipam_resource_discovery
2023/02/02 14:31:27 [DEBUG] Running Sweepers for region (us-east-1):
2023/02/02 14:31:27 [DEBUG] Running Sweeper (aws_vpc_ipam_resource_discovery) in region (us-east-1)
2023/02/02 14:31:27 [INFO] Retrieved credentials from "EnvConfigCredentials"
2023/02/02 14:31:27 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2023/02/02 14:31:27 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2023/02/02 14:31:27 [DEBUG] Waiting for state to become: [success]
2023/02/02 14:31:27 [DEBUG] Waiting for state to become: [success]
2023/02/02 14:31:27 [DEBUG] Deleting IPAMResourceDiscovery: ipam-res-disco-009445ae4ba7118d9
2023/02/02 14:31:27 [DEBUG] Deleting IPAMResourceDiscovery: ipam-res-disco-0b6ee7c578c4683ae
2023/02/02 14:31:27 [DEBUG] Waiting for state to become: []
2023/02/02 14:31:27 [DEBUG] Waiting for state to become: []
2023/02/02 14:31:32 [DEBUG] Completed Sweeper (aws_vpc_ipam_resource_discovery) in region (us-east-1) in 5.496641656s
2023/02/02 14:31:32 Completed Sweepers for region (us-east-1) in 5.496662633s
2023/02/02 14:31:32 Sweeper Tests for region (us-east-1) ran successfully:
        - aws_vpc_ipam_resource_discovery
2023/02/02 14:31:32 [DEBUG] Running Sweepers for region (us-east-2):
2023/02/02 14:31:32 [DEBUG] Running Sweeper (aws_vpc_ipam_resource_discovery) in region (us-east-2)
2023/02/02 14:31:32 [INFO] Retrieved credentials from "EnvConfigCredentials"
2023/02/02 14:31:32 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2023/02/02 14:31:33 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2023/02/02 14:31:33 [DEBUG] Completed Sweeper (aws_vpc_ipam_resource_discovery) in region (us-east-2) in 221.781903ms
2023/02/02 14:31:33 Completed Sweepers for region (us-east-2) in 221.805348ms
2023/02/02 14:31:33 Sweeper Tests for region (us-east-2) ran successfully:
        - aws_vpc_ipam_resource_discovery
ok      github.com/hashicorp/terraform-provider-aws/internal/sweep      6.414s

@drewmullen drewmullen changed the title [WIP] AWS IPAM Multi-Org ResourceDiscovery & ResourceDiscoveryAssociation AWS IPAM Multi-Org ResourceDiscovery & ResourceDiscoveryAssociation Feb 2, 2023
@drewmullen drewmullen added the partner Contribution from a partner. label Feb 2, 2023
@drewmullen
Copy link
Collaborator Author

tests still passing after adding missed err check

$ make testacc TESTS=TestAccIPAMResourceDiscovery_ PKG=ec2       
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccIPAMResourceDiscovery_'  -timeout 180m
=== RUN   TestAccIPAMResourceDiscovery_basic
=== PAUSE TestAccIPAMResourceDiscovery_basic
=== RUN   TestAccIPAMResourceDiscovery_modify
=== PAUSE TestAccIPAMResourceDiscovery_modify
=== RUN   TestAccIPAMResourceDiscovery_disappears
=== PAUSE TestAccIPAMResourceDiscovery_disappears
=== RUN   TestAccIPAMResourceDiscovery_tags
=== PAUSE TestAccIPAMResourceDiscovery_tags
=== CONT  TestAccIPAMResourceDiscovery_basic
=== CONT  TestAccIPAMResourceDiscovery_disappears
=== CONT  TestAccIPAMResourceDiscovery_tags
=== CONT  TestAccIPAMResourceDiscovery_modify
--- PASS: TestAccIPAMResourceDiscovery_disappears (24.52s)
--- PASS: TestAccIPAMResourceDiscovery_basic (27.07s)
--- PASS: TestAccIPAMResourceDiscovery_tags (45.28s)
--- PASS: TestAccIPAMResourceDiscovery_modify (84.15s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        84.259s

Copy link
Collaborator

@AdamTylerLynch AdamTylerLynch left a comment

Choose a reason for hiding this comment

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

Requesting a few changes related to context passing and documentation. Thank you so much for this PR!

@AdamTylerLynch
Copy link
Collaborator

LGTM 🚀

Copy link
Collaborator

@AdamTylerLynch AdamTylerLynch left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@ewbankkit ewbankkit self-assigned this Feb 16, 2023
@github-actions github-actions bot added the service/ec2 Issues and PRs that pertain to the ec2 service. label Feb 16, 2023
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 🚀.

% make testacc TESTARGS='-run=TestAccIPAMResourceDiscovery_serial/ResourceDiscovery' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccIPAMResourceDiscovery_serial/ResourceDiscovery -timeout 180m
=== RUN   TestAccIPAMResourceDiscovery_serial
=== PAUSE TestAccIPAMResourceDiscovery_serial
=== CONT  TestAccIPAMResourceDiscovery_serial
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscovery
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/basic
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/modify
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/disappears
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/tags
--- PASS: TestAccIPAMResourceDiscovery_serial (220.44s)
    --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscovery (220.44s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/basic (31.85s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/modify (101.10s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/disappears (26.86s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscovery/tags (60.62s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	228.465s
% make testacc TESTARGS='-run=TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation -timeout 180m
=== RUN   TestAccIPAMResourceDiscovery_serial
=== PAUSE TestAccIPAMResourceDiscovery_serial
=== CONT  TestAccIPAMResourceDiscovery_serial
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation/basic
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation/disappears
=== RUN   TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation/tags
--- PASS: TestAccIPAMResourceDiscovery_serial (97.72s)
    --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation (147.72s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation/basic (39.28s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation/disappears (39.15s)
        --- PASS: TestAccIPAMResourceDiscovery_serial/ResourceDiscoveryAssociation/tags (63.53s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	154.254s

@ewbankkit
Copy link
Contributor

@drewmullen Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit c95ffc6 into hashicorp:main Feb 16, 2023
@github-actions github-actions bot added this to the v4.55.0 milestone Feb 16, 2023
@github-actions
Copy link

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

@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 Mar 20, 2023
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. partner Contribution from a partner. provider Pertains to the provider itself, rather than any interaction with AWS. service/ec2 Issues and PRs that pertain to the ec2 service. service/ipam Issues and PRs that pertain to the ipam service. size/XL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. 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.

[New]: IPAM Resource Discovery & Association
3 participants