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_nginx_deployment - support NGINX App Protect WAF #27454

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

arpith-f5
Copy link
Contributor

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

NGINXaaS now supports NGINX App Protect WAF. In order to use WAF, customers need to explicitly enable it while creating/update their NGINXaaS deployment. This commit includes changes to support a new block nginx_app_protect in azurerm_nginx_deployment resource to enable/disable WAF while creation or updating an NGINXaaS deployment.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Manually tested create and update of a NGINXaaS deployment with WAF enabled/disabled

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_nginx_deployment - support NGINX App Protect WAF

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

NGINXaaS now supports NGINX App Protect WAF. This commit includes changes to enable/disable WAF while creation or updating an NGINXaaS deployment.
@arpith-f5 arpith-f5 changed the title NGINXaaS App Protect azurerm_nginx_deployment - support NGINX App Protect WAF Sep 20, 2024
@puneetsarna
Copy link
Contributor

Looks like some vendor checks are failing?

@puneetsarna
Copy link
Contributor

I like the newly flattened structure (less nested) to invoke this new feature as well 👍

@arpith-f5
Copy link
Contributor Author

Hi @katbyte @stephybun, when you get time would you be able to take a look at this PR. Thanks in advance!

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.

Hi, we have a test failure needing fixing:

------- Stdout: -------
=== RUN   TestAccNginxDeploymentDataSource_nginxappprotect
=== PAUSE TestAccNginxDeploymentDataSource_nginxappprotect
=== CONT  TestAccNginxDeploymentDataSource_nginxappprotect
    testcase.go:173: Step 1/1 error: Error running apply: exit status 1
        
        Error: scaling is required for `sku` 'standardv2_Monthly', please provide `capacity` or `auto_scale_profiles`
        
          with azurerm_nginx_deployment.test,
          on terraform_plugin_test.tf line 75, in resource "azurerm_nginx_deployment" "test":
          75: resource "azurerm_nginx_deployment" "test" {
        
        scaling is required for `sku` 'standardv2_Monthly', please provide `capacity`
        or `auto_scale_profiles`
--- FAIL: TestAccNginxDeploymentDataSource_nginxappprotect (92.49s)
FAIL

@puneetsarna
Copy link
Contributor

Hi @katbyte!! I see @arpith-f5 pushed a fix for the test. Can you please re-run the tests and see if the issue persists?

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 @arpith-f5 - i've given it a quick review and made some schema suggestions. let me know what you think

@@ -194,10 +196,74 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"web_application_firewall_settings": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

settings is redundant, so we can remove it to also be more consistent with the rest of the provider

Suggested change
"web_application_firewall_settings": {
"web_application_firewall": {

Copy link
Contributor

@puneetsarna puneetsarna Nov 5, 2024

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 fine but the swagger calls it WebApplicationFirewallSettings and so that translates here fine in the client.

We can also check what we are doing for other client tools and keep the provider consistent with that as well to provide a uniform experience.

Copy link
Contributor Author

@arpith-f5 arpith-f5 Nov 5, 2024

Choose a reason for hiding this comment

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

@katbyte I have been following the approach of keeping the provider consistent with the swagger spec which is the reason for using web_application_firewall_settings, activation_state and having the activation_state be an enum instead of a bool as per the swagger spec. I think deviating from the swagger spec will cause more confusion for users so would prefer to use the same naming. Do let me know if provider has a different set of naming convention that it needs to follow.

@@ -262,6 +285,24 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
}, false),
},

"web_application_firewall_settings": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

settings is redundant, so we can remove it to also be more consistent with the rest of the provider

Suggested change
"web_application_firewall_settings": {
"web_application_firewall": {

Optional: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"activation_state": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if the block becomes web_application_firewall this would be better as activated or enabled? which would make it more consistent with the rest of the provided

Copy link
Collaborator

Choose a reason for hiding this comment

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

addtionally is this the only setting that will be here or will there be further items

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine with either naming convention but would prefer what's already there as the WAF experience sounds fine to me. Will sync up with @arpith-f5 once to see if we want to change this.

@@ -351,6 +392,19 @@ func (m DeploymentResource) Attributes() map[string]*pluginsdk.Schema {
Type: pluginsdk.TypeString,
Computed: true,
},

"web_application_firewall_status": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if the above block becomes web_application_firewall this could go inside as web_application_firewall.status.x ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it could even be web_application_firewall.package_status.x and then web_application_firewall .component_versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially wanted to follow this approach of nesting the status inside the web_application_firewall block but the problem I encountered is that the status needs to be an attribute but settings is an argument. I didn't find a good way to have them both in the same block. Do you have any suggestions on how to do that?

Comment on lines +294 to +300
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(
[]string{
"Enabled",
"Disabled",
}, false),
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a bool? so we should

Suggested change
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(
[]string{
"Enabled",
"Disabled",
}, false),
Type: pluginsdk.TypeBool,
Required: true,

and then in the provider code translate true/false to Enabled Disabled, unless there is going to be a 3rd state here?

Copy link
Contributor

Choose a reason for hiding this comment

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

The state is an enum.

internal/services/nginx/nginx_deployment_resource.go Outdated Show resolved Hide resolved
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 @arpith-f5 - i've given it a quick review and made some schema suggestions. let me know what you think

@arpith-f5 arpith-f5 requested a review from a team as a code owner November 5, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants