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_managed_certificate can't parse custom hostname binding IDs for slots #27047

Open
1 task done
jaked opened this issue Aug 14, 2024 · 0 comments
Open
1 task done

Comments

@jaked
Copy link

jaked commented Aug 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

See #4240 (comment)

This is because azurerm_app_service_managed_certificate calls validate.AppServiceCustomHostnameBindingID which does not handle slots, see

ValidateFunc: validate.AppServiceCustomHostnameBindingID,
and
func AppServiceCustomHostnameBindingID(input string) (*AppServiceCustomHostnameBindingId, error) {

Terraform Version

1.8.1

AzureRM Provider Version

3.106.1

Affected Resource(s)/Data Source(s)

azurerm_app_service_managed_certificate

Terraform Configuration Files

resource "azurerm_linux_web_app" "example" { ... }

resource "azurerm_linux_web_app_slot" "example_staging" { ... }

resource "azurerm_app_service_custom_hostname_binding" "example_hostname_binding" {
    hostname            = "example.githubnext.com"
    app_service_name    = azurerm_linux_web_app.example.name
    resource_group_name = azurerm_resource_group.example_resource_group.name
}

resource "azurerm_app_service_managed_certificate" "example_cert" {
  custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.example_hostname_binding.id
}

resource "azurerm_app_service_certificate_binding" "example_certbinding" {
  hostname_binding_id = azurerm_app_service_custom_hostname_binding.example_hostname_binding.id
  certificate_id      = azurerm_app_service_managed_certificate.example_cert.id
  ssl_state           = "SniEnabled"
}

resource "azurerm_app_service_slot_custom_hostname_binding" "example_staging_hostname_binding" {
    hostname            = "example-staging.githubnext.com"
    app_service_slot_id = azurerm_linux_web_app_slot.example_staging.id
}

/*
fails with

  Error: can not parse "custom_hostname_binding_id" as App Service Custom Hostname ID: ID contained more segments than required

see

  https://github.com/hashicorp/terraform-provider-azurerm/issues/4240#issuecomment-1666075642

resource "azurerm_app_service_managed_certificate" "example_staging_cert" {
  custom_hostname_binding_id = azurerm_app_service_slot_custom_hostname_binding.example_staging_hostname_binding.id
}
*/

resource "azurerm_app_service_certificate_binding" "example_staging_certbinding" {
  hostname_binding_id = azurerm_app_service_slot_custom_hostname_binding.example_staging_hostname_binding.id
  certificate_id      = azurerm_app_service_managed_certificate.example_staging_cert.id
  ssl_state           = "SniEnabled"
}

Debug Output/Panic Output

Error: can not parse "custom_hostname_binding_id" as App Service Custom Hostname ID: ID contained more segments than required: "/subscriptions/6bb24934-9d49-45e1-bee2-5bc698af3517/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/example/slots/staging/hostNameBindings/example-staging.githubnext.com", map[slots:staging]

Expected Behaviour

managed certficate should have been created

Actual Behaviour

error as above

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@jaked jaked changed the title azurerm_app_service_certificate_binding can't parse custom hostname binding IDs for slots azurerm_app_service_managed_certificate can't parse custom hostname binding IDs for slots Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant