From d5d343bb562c3369fab986410822f383cc8f44ab Mon Sep 17 00:00:00 2001 From: bikerpatch <67706998+bikerpatch@users.noreply.github.com> Date: Fri, 17 Feb 2023 02:39:01 +0000 Subject: [PATCH] `azurerm_container_app` - allow multiple `container` blocks (#20423) --- .../container_app_resource_test.go | 141 ++++++++++++++++++ .../containerapps/helpers/container_apps.go | 1 - website/docs/r/container_app.html.markdown | 2 +- 3 files changed, 142 insertions(+), 2 deletions(-) diff --git a/internal/services/containerapps/container_app_resource_test.go b/internal/services/containerapps/container_app_resource_test.go index 6bd1137decb1..546cdd3e3bc8 100644 --- a/internal/services/containerapps/container_app_resource_test.go +++ b/internal/services/containerapps/container_app_resource_test.go @@ -158,6 +158,21 @@ func TestAccContainerAppResource_completeWithVNet(t *testing.T) { }) } +func TestAccContainerAppResource_completeWithSidecar(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_container_app", "test") + r := ContainerAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.completeWithSidecar(data, "rev1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccContainerAppResource_completeUpdate(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_container_app", "test") r := ContainerAppResource{} @@ -546,6 +561,132 @@ resource "azurerm_container_app" "test" { `, r.templateWithVnet(data), data.RandomInteger, revisionSuffix) } +func (r ContainerAppResource) completeWithSidecar(data acceptance.TestData, revisionSuffix string) string { + return fmt.Sprintf(` +%s + +resource "azurerm_container_app" "test" { + name = "acctest-capp-%[2]d" + resource_group_name = azurerm_resource_group.test.name + container_app_environment_id = azurerm_container_app_environment.test.id + revision_mode = "Single" + + template { + container { + name = "acctest-cont-sidecar-%[2]d" + image = "jackofallops/azure-containerapps-python-acctest:v0.0.1" + cpu = 0.25 + memory = "0.5Gi" + + readiness_probe { + transport = "HTTP" + port = 5000 + } + + liveness_probe { + transport = "HTTP" + port = 5000 + path = "/health" + + header { + name = "Cache-Control" + value = "no-cache" + } + + initial_delay = 5 + timeout = 2 + failure_count_threshold = 1 + } + + startup_probe { + transport = "TCP" + port = 5000 + } + + volume_mounts { + name = azurerm_container_app_environment_storage.test.name + path = "/tmp/testdata" + } + } + + container { + name = "acctest-cont-%[2]d" + image = "jackofallops/azure-containerapps-python-acctest:v0.0.1" + cpu = 0.25 + memory = "0.5Gi" + + readiness_probe { + transport = "HTTP" + port = 5000 + } + + liveness_probe { + transport = "HTTP" + port = 5000 + path = "/health" + + header { + name = "Cache-Control" + value = "no-cache" + } + + initial_delay = 5 + timeout = 2 + failure_count_threshold = 1 + } + + startup_probe { + transport = "TCP" + port = 5000 + } + + volume_mounts { + name = azurerm_container_app_environment_storage.test.name + path = "/tmp/testdata" + } + } + + volume { + name = azurerm_container_app_environment_storage.test.name + storage_type = "AzureFile" + storage_name = azurerm_container_app_environment_storage.test.name + } + + min_replicas = 2 + max_replicas = 3 + + revision_suffix = "%[3]s" + } + + ingress { + allow_insecure_connections = true + target_port = 5000 + transport = "http" + traffic_weight { + latest_revision = true + percentage = 100 + } + } + + registry { + server = azurerm_container_registry.test.login_server + username = azurerm_container_registry.test.admin_username + password_secret_name = "registry-password" + } + + secret { + name = "registry-password" + value = azurerm_container_registry.test.admin_password + } + + tags = { + foo = "Bar" + accTest = "1" + } +} +`, r.templatePlusExtras(data), data.RandomInteger, revisionSuffix) +} + func (r ContainerAppResource) completeChangedSecret(data acceptance.TestData, revisionSuffix string) string { return fmt.Sprintf(` %s diff --git a/internal/services/containerapps/helpers/container_apps.go b/internal/services/containerapps/helpers/container_apps.go index e46c786c7fdc..b103c43a6c38 100644 --- a/internal/services/containerapps/helpers/container_apps.go +++ b/internal/services/containerapps/helpers/container_apps.go @@ -643,7 +643,6 @@ func ContainerAppContainerSchema() *pluginsdk.Schema { Type: pluginsdk.TypeList, Required: true, MinItems: 1, - MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "name": { diff --git a/website/docs/r/container_app.html.markdown b/website/docs/r/container_app.html.markdown index aa467cf019e6..763b57778247 100644 --- a/website/docs/r/container_app.html.markdown +++ b/website/docs/r/container_app.html.markdown @@ -91,7 +91,7 @@ A `secret` block supports the following: A `template` block supports the following: -* `container` - (Required) A `container` block as detailed below. +* `container` - (Required) One or more `container` blocks as detailed below. * `max_replicas` - (Optional) The maximum number of replicas for this container.