diff --git a/internal/services/nginx/nginx_configuration_resource_test.go b/internal/services/nginx/nginx_configuration_resource_test.go index 2369b8308b53..1c69e4a45129 100644 --- a/internal/services/nginx/nginx_configuration_resource_test.go +++ b/internal/services/nginx/nginx_configuration_resource_test.go @@ -45,6 +45,20 @@ func TestAccConfiguration_basic(t *testing.T) { }) } +func TestAccConfiguration_withCertificate(t *testing.T) { + data := acceptance.BuildTestData(t, nginx.ConfigurationResource{}.ResourceType(), "test") + r := ConfigurationResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.withCertificate(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccConfiguration_update(t *testing.T) { data := acceptance.BuildTestData(t, nginx.ConfigurationResource{}.ResourceType(), "test") r := ConfigurationResource{} @@ -103,6 +117,49 @@ resource "azurerm_nginx_configuration" "test" { `, a.template(data)) } +func (a ConfigurationResource) withCertificate(data acceptance.TestData) string { + return fmt.Sprintf(` + +%s + +locals { + config_content = base64encode(<<-EOT +http { + server { + listen 443 ssl; + ssl_certificate /etc/nginx/ssl/test.crt; + ssl_certificate_key /etc/nginx/ssl/test.key; + location / { + return 200 "Hello World"; + } + } +} +EOT + ) +} + +resource "azurerm_nginx_certificate" "test" { + name = "acctest" + nginx_deployment_id = azurerm_nginx_deployment.test.id + key_virtual_path = "/etc/nginx/ssl/test.key" + certificate_virtual_path = "/etc/nginx/ssl/test.crt" + key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id +} + +resource "azurerm_nginx_configuration" "test" { + nginx_deployment_id = azurerm_nginx_deployment.test.id + root_file = "/etc/nginx/nginx.conf" + + config_file { + content = local.config_content + virtual_path = "/etc/nginx/nginx.conf" + } + + depends_on = [azurerm_nginx_certificate.test] +} +`, CertificateResource{}.template(data)) +} + func (a ConfigurationResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` diff --git a/internal/services/nginx/nginx_deployment_resource_test.go b/internal/services/nginx/nginx_deployment_resource_test.go index de7ad0878bb2..8a00fa0fb959 100644 --- a/internal/services/nginx/nginx_deployment_resource_test.go +++ b/internal/services/nginx/nginx_deployment_resource_test.go @@ -300,7 +300,7 @@ resource "azurerm_nginx_deployment" "test" { subnet_id = azurerm_subnet.test.id } capacity = 10 - email = "test@test.com" + email = "test@test.com" configuration { root_file = "/etc/nginx/nginx.conf" config_file { diff --git a/website/docs/d/nginx_configuration.html.markdown b/website/docs/d/nginx_configuration.html.markdown index f944cca4fc82..f75096daa76e 100644 --- a/website/docs/d/nginx_configuration.html.markdown +++ b/website/docs/d/nginx_configuration.html.markdown @@ -1,5 +1,5 @@ --- -subcategory: "Nginx" +subcategory: "NGINX" layout: "azurerm" page_title: "Azure Resource Manager: Data Source: azurerm_nginx_configuration" description: |- diff --git a/website/docs/r/nginx_configuration.html.markdown b/website/docs/r/nginx_configuration.html.markdown index ddbc16ecb946..f060c2373c71 100644 --- a/website/docs/r/nginx_configuration.html.markdown +++ b/website/docs/r/nginx_configuration.html.markdown @@ -1,5 +1,5 @@ --- -subcategory: "Nginx" +subcategory: "NGINX" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_nginx_configuration" description: |-