hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Support for volume mount options in azurerm_container_app #26131

Open riskpoint-per opened 5 months ago

riskpoint-per commented 5 months ago

Is there an existing issue for this?

Community Note

Description

When adding a volume to the container, there should be a comma separated list of mount options, like in the image below.

image

New or Affected Resource(s)/Data Source(s)

azurerm_container_app

Potential Terraform Configuration

resource "azurerm_container_app" "example" {
  name                         = "example-app"
  container_app_environment_id = azurerm_container_app_environment.example.id
  resource_group_name          = azurerm_resource_group.example.name
  revision_mode                = "Single"

  ingress {
    target_port = 1234
    # The new item:
    additional_port_mapping {
      external_enabled = true
      target_port = 4321
    }
    additional_port_mapping {
      target_port = 2345
    }
  }

  template {
    container {
      name   = "examplecontainerapp"
      image  = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest"
      cpu    = 0.25
      memory = "0.5Gi"

      volume_mounts {
        name = "example"
        path = "/tmp/"
      }
    }

    volume {
      name         = "example"
      storage_type = "AzureFile"
      storage_name = azurerm_container_app_environment_storage.example.name
      # The new item:
      mount_options: [ "uid=999", "gid=999", "hard" ]
    }
  }
}

References

No response

kawahara-titan commented 4 months ago

This would be a nice feature. Until then, is using the azapi_update_resource to add the mountOption like below a potential workaround?

resource "azapi_update_resource" "update_resource" {
  name = "my_containerapp_resource"
  parent_id = data.azurerm_resource_group.rg.id
  type = "Microsoft.App/containerApps@2024-03-01"
  body = jsonencode({
    properties = {
      template = {
        volumes = [
          {
            mountOptions = "dir_mode=0777,file_mode=0777"
          }
        ]
      }
    }
  })
}
matthieupetite commented 4 months ago

This would be a nice feature. Until then, is using the azapi_update_resource to add the mountOption like below a potential workaround?

resource "azapi_update_resource" "update_resource" {
  name = "my_containerapp_resource"
  parent_id = data.azurerm_resource_group.rg.id
  type = "Microsoft.App/containerApps@2024-03-01"
  body = jsonencode({
    properties = {
      template = {
        volumes = [
          {
            mountOptions = "dir_mode=0777,file_mode=0777"
          }
        ]
      }
    }
  })
}

Don't forget the revision suffix in the template otherwise the update will not work. But unfortunatly it trigger tow revision instead one :(. It works indeed but we really need the fix

mapperCoderZ commented 3 months ago

any update on this ? we want to go live production, this is necessary for securing our landing zone