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, azurerm_app_service_slot, azurerm_function_app: Support for site_config.ip_restrictions.headers / site_config.scm_ip_restrictions.headers #11209

Merged
merged 7 commits into from
Apr 27, 2021

Conversation

aristosvo
Copy link
Collaborator

@aristosvo aristosvo commented Apr 2, 2021

Fixes #11156

Example

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_frontdoor" "example" {
  name                                         = "example-frontdoor-2191"
  resource_group_name                          = azurerm_resource_group.example.name
  enforce_backend_pools_certificate_name_check = false

  routing_rule {
    name               = "exampleRoutingRule1"
    accepted_protocols = ["Http", "Https"]
    patterns_to_match  = ["/*"]
    frontend_endpoints = ["exampleFrontendEndpoint1"]
    forwarding_configuration {
      forwarding_protocol = "MatchRequest"
      backend_pool_name   = "exampleBackendBing"
    }
  }

  backend_pool_load_balancing {
    name = "exampleLoadBalancingSettings1"
  }

  backend_pool_health_probe {
    name = "exampleHealthProbeSetting1"
  }

  backend_pool {
    name = "exampleBackendBing"
    backend {
      host_header = "www.bing.com"
      address     = "www.bing.com"
      http_port   = 80
      https_port  = 443
    }

    load_balancing_name = "exampleLoadBalancingSettings1"
    health_probe_name   = "exampleHealthProbeSetting1"
  }

  frontend_endpoint {
    name                              = "exampleFrontendEndpoint1"
    host_name                         = "example-frontdoor-2191.azurefd.net"
  }
}

resource "azurerm_app_service_plan" "example" {
  name                = "example-appserviceplan"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  sku {
    tier = "Standard"
    size = "S1"
  }
}

resource "azurerm_app_service" "example" {
  name                = "example-app-service-2191"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_app_service_plan.example.id

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type = "None"

    scm_ip_restriction {
        action     = "Allow"
        name       = "test"
        ip_address = "8.8.8.8/32"
        priority   = 100
        headers {
            x_azure_fdid      = [azurerm_frontdoor.example.header_frontdoor_id]
            x_fd_health_probe = ["1"]
            x_forwarded_for   = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
            x_forwarded_host  = ["example.com"]
        }
    }
  }

  app_settings = {
    "SOME_KEY" = "some-value"
  }

  connection_string {
    name  = "Database"
    type  = "SQLServer"
    value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
  }
}

Acceptance Tests

  • Included in existing AccTest for ip_restrictions
  • For create, update and explicit delete: TestAccAppService_zeroedIpRestrictionHeaders
  • Docs

@ghost ghost added the size/M label Apr 2, 2021
@aristosvo aristosvo force-pushed the app-service-tag-headers branch from a727be8 to bd612de Compare April 20, 2021 14:16
@ghost ghost added size/L documentation and removed size/M labels Apr 20, 2021
@aristosvo aristosvo force-pushed the app-service-tag-headers branch from bebbf0b to 28c1cb1 Compare April 20, 2021 18:16
@aristosvo aristosvo force-pushed the app-service-tag-headers branch from 28c1cb1 to e573085 Compare April 20, 2021 18:44
@ghost ghost added size/XL and removed size/L labels Apr 20, 2021
@aristosvo
Copy link
Collaborator Author

aristosvo commented Apr 20, 2021

I believe it's now complete and ready for a thorough review:

❯ make acctests SERVICE='web' TESTARGS='-run=TestAccAppService_zeroedIpRestrictionHeaders'
==> 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 -v ./azurerm/internal/services/web -run=TestAccAppService_zeroedIpRestrictionHeaders -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
2021/04/20 20:44:39 [DEBUG] not using binary driver name, it's no longer needed
2021/04/20 20:44:40 [DEBUG] not using binary driver name, it's no longer needed
=== RUN   TestAccAppService_zeroedIpRestrictionHeaders
=== PAUSE TestAccAppService_zeroedIpRestrictionHeaders
=== CONT  TestAccAppService_zeroedIpRestrictionHeaders
--- PASS: TestAccAppService_zeroedIpRestrictionHeaders (400.28s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web     403.909s

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 @aristosvo - Thanks for the updates!

Could you add in the necessary lint ignores for the Sets with MaxItems (S018 - see the changed files tab), whilst not a fail, this will help us keep the linting clean.

I think it's also worth adding an additional note to the docs for these new properties to ensure users are aware that these headers are combined with the other settings so if used, all items must match for the rule to apply. WDYT?

Otherwise this LGTM so we should be able to get this merged as soon as this is done. 👍

@aristosvo
Copy link
Collaborator Author

Thanks! Fixed it, will check later today if it complies to all linting.

@katbyte katbyte added this to the v2.57.0 milestone Apr 27, 2021
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 @aristosvo - LGTM 👍

@katbyte katbyte merged commit fa4b08c into hashicorp:master Apr 27, 2021
katbyte added a commit that referenced this pull request Apr 27, 2021
alvintang pushed a commit to alvintang/terraform-provider-azurerm that referenced this pull request Apr 29, 2021
…app`: Support for site_config.ip_restrictions.headers / site_config.scm_ip_restrictions.headers (hashicorp#11209)

Fixes hashicorp#11156
alvintang pushed a commit to alvintang/terraform-provider-azurerm that referenced this pull request Apr 29, 2021
@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 2.57.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.57.0"
}
# ... other configuration ...

@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 contributions.
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 May 30, 2021
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 Azure service_tag headers in ip_restrictions azurerm_app_service
3 participants