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

new resource: azurerm_firewall_policy_rule_collection_group #8603

Merged

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Sep 24, 2020

Test Result

💤 make testacc TEST=./azurerm/internal/services/network/tests TESTARGS='-run TestAccAzureRMFirewallPolicyRuleCollectionGroup'

==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test ./azurerm/internal/services/network/tests -v -run TestAccAzureRMFirewallPolicyRuleCollectionGroup -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccAzureRMFirewallPolicyRuleCollectionGroup_basic
=== PAUSE TestAccAzureRMFirewallPolicyRuleCollectionGroup_basic
=== RUN   TestAccAzureRMFirewallPolicyRuleCollectionGroup_complete
=== PAUSE TestAccAzureRMFirewallPolicyRuleCollectionGroup_complete
=== RUN   TestAccAzureRMFirewallPolicyRuleCollectionGroup_update
=== PAUSE TestAccAzureRMFirewallPolicyRuleCollectionGroup_update
=== RUN   TestAccAzureRMFirewallPolicyRuleCollectionGroup_requiresImport
=== PAUSE TestAccAzureRMFirewallPolicyRuleCollectionGroup_requiresImport
=== CONT  TestAccAzureRMFirewallPolicyRuleCollectionGroup_basic
=== CONT  TestAccAzureRMFirewallPolicyRuleCollectionGroup_requiresImport
=== CONT  TestAccAzureRMFirewallPolicyRuleCollectionGroup_update
=== CONT  TestAccAzureRMFirewallPolicyRuleCollectionGroup_complete
--- PASS: TestAccAzureRMFirewallPolicyRuleCollectionGroup_basic (124.12s)
--- PASS: TestAccAzureRMFirewallPolicyRuleCollectionGroup_complete (124.13s)
--- PASS: TestAccAzureRMFirewallPolicyRuleCollectionGroup_requiresImport (134.30s)
--- PASS: TestAccAzureRMFirewallPolicyRuleCollectionGroup_update (216.12s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/network/tests       216.163s

Related issue: #7319

@magodo magodo force-pushed the firewall_policy_rule_collection_group branch from 3ffeee0 to 9e5627d Compare September 28, 2020 05:08
@tombuildsstuff tombuildsstuff modified the milestones: v2.30.0, v2.31.0 Oct 1, 2020
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @magodo - overall this is looking good and i've left some comments inline.

@magodo
Copy link
Collaborator Author

magodo commented Oct 12, 2020

@katbyte I have updated the code per your review comments, please take another look!

@jackofallops jackofallops modified the milestones: v2.32.0, v2.33.0 Oct 15, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.33.0, v2.34.0 Oct 22, 2020
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Hi @magodo, this is looking great. I have one more suggestion and a couple questions below if you could help me understand some of the design decisions. Thanks!

Name string
}

func FirewallPolicyRuleCollectionGroupID(input string) (*FirewallPolicyRuleCollectionGroupId, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make this function use azure.ParseAzureResourceID rather than depending on FirewallPolicyID and a regex match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

return err
}

policyResp, err := policyClient.Get(ctx, id.ResourceGroup, id.PolicyName, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to check the existence of the linked policy before retrieving the rule collection group?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason is that we will need to use the policyResp to set the firewall_policy_id later. Instead, we should opt in to using the ID Formatter to save this API call.

ValidateFunc: validation.StringIsNotEmpty,
},
},
"destination_address": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we accept a single address/CIDR when the API accepts a list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The API actually doesn't support a list, it will raise error:

Invalid DNat destination address. Multiple values, ranges and * are not supported.

@magodo
Copy link
Collaborator Author

magodo commented Oct 29, 2020

@manicminer I have updated per your commments, please take another look, thank you!

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@magodo Thanks, there's one other issue I noticed - can we store the subscription ID in the FirewallPolicyId and FirewallPolicyRuleCollectionGroupId structs, taking it from the original ID string, instead of passing it in afterwards?

@manicminer manicminer modified the milestones: v2.34.0, v2.35.0 Oct 29, 2020
@magodo
Copy link
Collaborator Author

magodo commented Oct 30, 2020

@manicminer I assume you mean this part, this is actually how the Formatter interface defined, and is used prevalently elsewhere.

@manicminer
Copy link
Contributor

@magodo Ah ok thanks. I still prefer the subscriptionId be sourced from the resource rather than from the client, but this looks good to merge 👍

@manicminer manicminer changed the title new resource /data source: azurerm_firewall_policy_rule_collection_group new resource: azurerm_firewall_policy_rule_collection_group Oct 30, 2020
@manicminer manicminer merged commit 94561a6 into hashicorp:master Oct 30, 2020
manicminer added a commit that referenced this pull request Oct 30, 2020
@manicminer
Copy link
Contributor

Test results:

Screenshot 2020-10-30 at 18 14 52

@magodo
Copy link
Collaborator Author

magodo commented Nov 2, 2020

@manicminer TBH, my first adoptions to the id structures imbedded the subscriptionId inside 😅

@ghost
Copy link

ghost commented Nov 5, 2020

This has been released in version 2.35.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.35.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Nov 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants