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

azurerm_app_service ip_restriction - support for name & priority #6705

Merged
merged 10 commits into from May 7, 2020
Merged

azurerm_app_service ip_restriction - support for name & priority #6705

merged 10 commits into from May 7, 2020

Conversation

aqche
Copy link
Contributor

@aqche aqche commented Apr 30, 2020

Fixes: #6388

Adds the name and priority options to the azurerm_app_service resource's ip_restriction option.

=== RUN   TestAccAzureRMAppService_completeIpRestriction
=== PAUSE TestAccAzureRMAppService_completeIpRestriction
=== CONT  TestAccAzureRMAppService_completeIpRestriction
--- PASS: TestAccAzureRMAppService_completeIpRestriction (143.55s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/tests   143.564s
=== RUN   TestAccDataSourceAzureRMAppService_ipRestriction
=== PAUSE TestAccDataSourceAzureRMAppService_ipRestriction
=== CONT  TestAccDataSourceAzureRMAppService_ipRestriction
--- PASS: TestAccDataSourceAzureRMAppService_ipRestriction (147.63s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/tests   147.645s

Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(1),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you check here as well if priority is maximum 65000?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call

Copy link
Contributor Author

@aqche aqche May 1, 2020

Choose a reason for hiding this comment

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

are you sure about the max value being 65000? after some testing, it looks like the max value I can set for priority is 2147483647. If I go above that, priority will be set to a negative value.

Copy link
Contributor

Choose a reason for hiding this comment

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

good question actually. I just tried to set a rule via az powershell:
Add-AzWebAppAccessRestrictionRule: Cannot validate argument on parameter 'Priority'. The 65001 argument is greater than the maximum allowed range of 65000. Supply an argument that is less than or equal to 65000 and then try the command again.

The portal lets you also set something larger than 65000 and enforces the limit at 2147483647. So I guess you are right, that should be it.

@@ -309,6 +309,10 @@ A `ip_restriction` block supports the following:

-> **NOTE:** One of either `ip_address` or `virtual_network_subnet_id` must be specified

* `name` - (Optional) The name for this IP Restriction.

* `priority` - (Optional) The priority for this IP Restriction. Restrictions are enforced in priority order.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a note that it defaults to 65000

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, thanks for the info

"priority": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as @sebader noted, priority defaults to 65000 when not provided. Should we make that an explicit default or let it be computed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure where the default of 65000 is injected in this case. Might be in the Go SDK? Since in CLI, Powershell and the portal the parameter must be manually specified, there is no default there.

Copy link
Contributor

Choose a reason for hiding this comment

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

So might actually be better so explicitly set it?!

@sebader
Copy link
Contributor

sebader commented May 4, 2020

nice, looks good to me know @aqche Thank you!

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @aqche
Thanks for this PR. Just a few minor changes needed and I think this should be good to merge.

Ste

Comment on lines 319 to 323
"name": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
Copy link
Member

Choose a reason for hiding this comment

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

I think we'll want Computed: true, on here.

Comment on lines 324 to 329
"priority": {
Type: schema.TypeInt,
Optional: true,
Default: 65000,
ValidateFunc: validation.IntBetween(1, 2147483647),
},
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be Computed: true, rather than setting a default. If more than one IP Restriction is used this could cause a conflict. The "default" value is assigned by the platform, rather than it being in the SDK, so can safely be read back from the API if not explicitly set.

@@ -514,6 +514,27 @@ func TestAccAzureRMAppService_oneIpRestriction(t *testing.T) {
})
}

func TestAccAzureRMAppService_completeIpRestriction(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we have an additional test that updates an app_service by adding, then removing, a 2nd ip_restriction? (or extend this one)

@ghost ghost added size/L and removed size/M labels May 6, 2020
@aqche
Copy link
Contributor Author

aqche commented May 6, 2020

@jackofallops thanks for the review! made the updates you suggested. let me know what you think!

=== RUN   TestAccAzureRMAppService_completeIpRestriction
=== PAUSE TestAccAzureRMAppService_completeIpRestriction
=== CONT  TestAccAzureRMAppService_completeIpRestriction
--- PASS: TestAccAzureRMAppService_completeIpRestriction (266.53s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/tests   266.555s

@ghost ghost removed the waiting-response label May 6, 2020
@jackofallops
Copy link
Member

image
Failures are transient at Azure side.

@jackofallops jackofallops merged commit 59f2ddd into hashicorp:master May 7, 2020
jackofallops added a commit that referenced this pull request May 7, 2020
@bentterp
Copy link
Contributor

bentterp commented May 8, 2020

When I compare with the configuration options in the Azure portal, it seems that the action "allow/deny" is missing.

If there were no deny rules, then there would be no need for assigning priorities - similar to NSG rules.

@ghost
Copy link

ghost commented Jun 6, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Jun 6, 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.

Support for name and priority in ip_restriction of azurerm_app_service
5 participants