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.59k stars 4.62k forks source link

azurerm_container_group container volume incorrect or inaccurate error message "only one of empty_dir volume, git_repo volume, secret volume or storage account volume" #18778 #24870

Open saulobejo opened 8 months ago

saulobejo commented 8 months ago

Is there an existing issue for this?

Community Note

Description

This is not true anymore. The Azure API now accepts more than one volume

https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files#mount-multiple-volumes

o mount multiple volumes in a container instance, you must deploy using an [Azure Resource Manager template](https://learn.microsoft.com/en-us/azure/templates/microsoft.containerinstance/containergroups), a YAML file, or another programmatic method. To use a template or YAML file, provide the share details and define the volumes by populating the volumes array in the properties section of the file.

For example, if you created two Azure Files shares named share1 and share2 in storage account myStorageAccount, the volumes array in a Resource Manager template would appear similar to the following
"volumes": [{
  "name": "myvolume1",
  "azureFile": {
    "shareName": "share1",
    "storageAccountName": "myStorageAccount",
    "storageAccountKey": "<storage-account-key>"
  }
},
{
  "name": "myvolume2",
  "azureFile": {
    "shareName": "share2",
    "storageAccountName": "myStorageAccount",
    "storageAccountKey": "<storage-account-key>"
  }
}]
Next, for each container in the container group in which you'd like to mount the volumes, populate the volumeMounts array in the properties section of the container definition. For example, this mounts the two volumes, myvolume1 and myvolume2, previously defined:
"volumeMounts": [{
  "name": "myvolume1",
  "mountPath": "/mnt/share1/"
},
{
  "name": "myvolume2",
  "mountPath": "/mnt/share2/"
}]

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

azurerm_container_group

Potential Terraform Configuration

resource "azurerm_container_group" "example" {
  name                = "example-continst"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  ip_address_type     = "Public"
  dns_name_label      = "aci-label"
  os_type             = "Linux"

  container {
    name   = "hello-world"
    image  = "mcr.microsoft.com/azuredocs/aci-helloworld:latest"
    cpu    = "0.5"
    memory = "1.5"

    volume_mount {
      name = "myvolume1"
      mountPath = "/mnt/share1/"
    }
    volume_mount {
      name = "myvolume2"
      mountPath = "/mnt/share2/"
    }

  volume {
    name = "myvolume1"
    azureFile = {
      share_name = "share1"
      storage_account_name = "myStorageAccount"
      storage_account_key = "<storage-account-key>"
    }
  }

  volume {
    name = "myvolume2"
    azureFile = {
      share_name = "share2"
      storage_account_name = "myStorageAccount"
      storage_account_key = "<storage-account-key>"
    }
  }
}

References

No response

davidkarlsen commented 8 months ago

Docs showing this in ARM: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-emptydir