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

r/aws_resourcegroups_group: Make resource_query and configuration not conflict #30242

Merged
merged 14 commits into from
Jun 29, 2023

Conversation

codablock
Copy link
Contributor

@codablock codablock commented Mar 24, 2023

Description

This PR changes aws_resourcegroups_group to not conflict the two blocks "resource_query" and "configuration".

AWS has recentry introduced tag based resource groups support for the network firewall.

This requires to create a resource group that has a resource query configured AND a configuration block that changes the type to AWS::NetworkFirewall::RuleGroup (docs here). This currently however causes a conflict in terraform as it forbids setting resource_query and configuration at the same time.

With this PR, creating such resource groups becomes possible. I tested this with the following resource:

resource "aws_resourcegroups_group" "my-rg" {
  name = "my-rg"
  resource_query {
    query = <<JSON
{
  "ResourceTypeFilters": [
    "AWS::EC2::Instance",
    "AWS::EC2::NetworkInterface"
  ],
  "TagFilters": [
    {
      "Key": "my-tag",
      "Values": ["my-value"]
    }
  ]
}
JSON
}
  configuration {
    type = "AWS::NetworkFirewall::RuleGroup"
  }
}

Closes #31843.

References

https://aws.amazon.com/about-aws/whats-new/2023/02/aws-network-firewall-tag-based-resource-groups/
https://docs.aws.amazon.com/ARG/latest/userguide/about-slg.html#about-slg-types-network-firewall-rulegroup

Output from Acceptance Testing

$ make testacc TESTS="TestAccResourceGroupsGroup_" PKG=resourcegroups
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/resourcegroups/... -v -count 1 -parallel 20 -run='TestAccResourceGroupsGroup_'  -timeout 180m
=== RUN   TestAccResourceGroupsGroup_basic
=== PAUSE TestAccResourceGroupsGroup_basic
=== RUN   TestAccResourceGroupsGroup_tags
=== PAUSE TestAccResourceGroupsGroup_tags
=== RUN   TestAccResourceGroupsGroup_Configuration
=== PAUSE TestAccResourceGroupsGroup_Configuration
=== RUN   TestAccResourceGroupsGroup_configurationParametersOptional
=== PAUSE TestAccResourceGroupsGroup_configurationParametersOptional
=== RUN   TestAccResourceGroupsGroup_resourceQueryAndConfiguration
=== PAUSE TestAccResourceGroupsGroup_resourceQueryAndConfiguration
=== CONT  TestAccResourceGroupsGroup_basic
=== CONT  TestAccResourceGroupsGroup_configurationParametersOptional
=== CONT  TestAccResourceGroupsGroup_Configuration
=== CONT  TestAccResourceGroupsGroup_resourceQueryAndConfiguration
=== CONT  TestAccResourceGroupsGroup_tags
--- PASS: TestAccResourceGroupsGroup_configurationParametersOptional (31.83s)
--- PASS: TestAccResourceGroupsGroup_resourceQueryAndConfiguration (31.90s)
--- PASS: TestAccResourceGroupsGroup_basic (51.03s)
--- PASS: TestAccResourceGroupsGroup_tags (68.73s)
--- PASS: TestAccResourceGroupsGroup_Configuration (77.67s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroups     80.118s
...

@github-actions
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 needs-triage Waiting for first response or review from a maintainer. service/resourcegroups Issues and PRs that pertain to the resourcegroups service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/resourcegroups Issues and PRs that pertain to the resourcegroups service. labels Mar 24, 2023
@DrFaust92 DrFaust92 added service/resourcegroups Issues and PRs that pertain to the resourcegroups service. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 27, 2023
@DrFaust92
Copy link
Collaborator

codablock Missing changelog, can you go over contribution guide?

@DrFaust92 DrFaust92 added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Mar 27, 2023
@codablock
Copy link
Contributor Author

@DrFaust92 Added a changelog file/entry :)

@codablock
Copy link
Contributor Author

Any chance to get a review here?

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. enhancement Requests to existing resources that expand the functionality or scope. crash Results from or addresses a Terraform crash or kernel panic. labels Jun 29, 2023
@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jun 29, 2023
@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. service/ssmincidents Issues and PRs that pertain to the ssmincidents service. and removed size/L Managed by automation to categorize the size of a PR. labels Jun 29, 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=TestAccResourceGroupsGroup_' PKG=resourcegroups ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/resourcegroups/... -v -count 1 -parallel 2  -run=TestAccResourceGroupsGroup_ -timeout 180m
=== RUN   TestAccResourceGroupsGroup_basic
=== PAUSE TestAccResourceGroupsGroup_basic
=== RUN   TestAccResourceGroupsGroup_tags
=== PAUSE TestAccResourceGroupsGroup_tags
=== RUN   TestAccResourceGroupsGroup_Configuration
=== PAUSE TestAccResourceGroupsGroup_Configuration
=== RUN   TestAccResourceGroupsGroup_configurationParametersOptional
=== PAUSE TestAccResourceGroupsGroup_configurationParametersOptional
=== RUN   TestAccResourceGroupsGroup_resourceQueryAndConfiguration
=== PAUSE TestAccResourceGroupsGroup_resourceQueryAndConfiguration
=== CONT  TestAccResourceGroupsGroup_basic
=== CONT  TestAccResourceGroupsGroup_configurationParametersOptional
--- PASS: TestAccResourceGroupsGroup_configurationParametersOptional (26.95s)
=== CONT  TestAccResourceGroupsGroup_resourceQueryAndConfiguration
--- PASS: TestAccResourceGroupsGroup_basic (45.38s)
=== CONT  TestAccResourceGroupsGroup_Configuration
--- PASS: TestAccResourceGroupsGroup_resourceQueryAndConfiguration (26.38s)
=== CONT  TestAccResourceGroupsGroup_tags
--- PASS: TestAccResourceGroupsGroup_tags (63.51s)
--- PASS: TestAccResourceGroupsGroup_Configuration (73.07s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroups	123.921s
% make testacc TESTARGS='-run=TestAccResourceGroupsResource_' PKG=resourcegroups 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/resourcegroups/... -v -count 1 -parallel 20  -run=TestAccResourceGroupsResource_ -timeout 180m
=== RUN   TestAccResourceGroupsResource_basic
=== PAUSE TestAccResourceGroupsResource_basic
=== CONT  TestAccResourceGroupsResource_basic
--- PASS: TestAccResourceGroupsResource_basic (26.49s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroups	32.163s
% make sweep SWEEPARGS=-sweep-run=aws_resourcegroups_group
# 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_resourcegroups_group -timeout 60m
2023/06/29 11:34:22 [DEBUG] Running Sweepers for region (us-west-2):
2023/06/29 11:34:22 [DEBUG] Running Sweeper (aws_resourcegroups_group) in region (us-west-2)
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-4156072979504175319
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-3237009494218269245
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-5323803557228335846
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-8609933339003332924
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-4987950737488137534
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-2867155452020362352
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-4022458543988726902
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: test-group-1970219225215566345
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-8514890133925320257
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-3556904857257078244
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-6879907987582139300
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-6698149265625212243
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-7076610115531334639
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-4370588089895096134
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-7112314810095621238
2023/06/29 11:34:23 [DEBUG] Waiting for state to become: [success]
2023/06/29 11:34:23 [DEBUG] Deleting Resource Groups Group: tf-acc-test-6852960003045699462
2023/06/29 11:34:24 [DEBUG] Completed Sweeper (aws_resourcegroups_group) in region (us-west-2) in 2.185899048s
2023/06/29 11:34:24 Completed Sweepers for region (us-west-2) in 2.186163975s
2023/06/29 11:34:24 Sweeper Tests for region (us-west-2) ran successfully:
	- aws_resourcegroups_group
2023/06/29 11:34:24 [DEBUG] Running Sweepers for region (us-east-1):
2023/06/29 11:34:24 [DEBUG] Running Sweeper (aws_resourcegroups_group) in region (us-east-1)
2023/06/29 11:34:25 [DEBUG] Completed Sweeper (aws_resourcegroups_group) in region (us-east-1) in 551.764714ms
2023/06/29 11:34:25 Completed Sweepers for region (us-east-1) in 551.845073ms
2023/06/29 11:34:25 Sweeper Tests for region (us-east-1) ran successfully:
	- aws_resourcegroups_group
2023/06/29 11:34:25 [DEBUG] Running Sweepers for region (us-east-2):
2023/06/29 11:34:25 [DEBUG] Running Sweeper (aws_resourcegroups_group) in region (us-east-2)
2023/06/29 11:34:25 [DEBUG] Completed Sweeper (aws_resourcegroups_group) in region (us-east-2) in 617.943764ms
2023/06/29 11:34:25 Completed Sweepers for region (us-east-2) in 618.012871ms
2023/06/29 11:34:25 Sweeper Tests for region (us-east-2) ran successfully:
	- aws_resourcegroups_group
ok  	github.com/hashicorp/terraform-provider-aws/internal/sweep	8.712s

@ewbankkit
Copy link
Contributor

@codablock Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 5c61579 into hashicorp:main Jun 29, 2023
39 checks passed
@github-actions github-actions bot added this to the v5.6.0 milestone Jun 29, 2023
@github-actions
Copy link

This functionality has been released in v5.6.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 Jul 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. enhancement Requests to existing resources that expand the functionality or scope. service/resourcegroups Issues and PRs that pertain to the resourcegroups service. service/ssmincidents Issues and PRs that pertain to the ssmincidents 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.

[Bug]: "panic interfacs convertion" when trying to create a aws_resourcegroups_resource resource
3 participants