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

azurerm_container_group causes http/500 when created using documented cpu = "0.5" requires cpu = "1.0" or higher #26925

Closed mattduguid closed 3 months ago

mattduguid commented 3 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.2

AzureRM Provider Version

terraform-provider-azurerm_v3.114.0_x5

Affected Resource(s)/Data Source(s)

azurerm_container_group

Terraform Configuration Files

resource "azurerm_container_group" "azure" {
  name = "test1234567890"
  location = azurerm_resource_group.azure.location
  resource_group_name = azurerm_resource_group.azure.name
  ip_address_type = "Public"
  dns_name_label = "test1234567890"
  os_type = "Linux"

  container {
    name = "test1234567890"
    image = "${azurerm_container_registry.azure.login_server}/test1234567890:latest"
    cpu = "0.5" # <-- this value being 0.5 as per documentation caused the error, changed to 1.0 and worked without http/500
    memory = "1.5"

    ports {
      port = 80
      protocol = "TCP"
    }
  }

  exposed_port {
    port     = 80
    protocol = "TCP"
  }

  image_registry_credential {
    server   = azurerm_container_registry.azure.login_server
    username = azurerm_container_registry.azure.admin_username
    password = azurerm_container_registry.azure.admin_password
  }
}

Debug Output/Panic Output

...etc...
module.<NAME>.azurerm_container_group.example: Still creating... [12m40s elapsed]
module.<NAME>.azurerm_container_group.example: Still creating... [12m50s elapsed]
module.<NAME>.azurerm_container_group.example: Still creating... [13m0s elapsed]
2024-08-05T02:08:39.585Z [DEBUG] provider.terraform-provider-azurerm_v3.114.0_x5: PUT https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerInstance/containerGroups/<CONTAINER_GROUP>?api-version=2023-05-01 (status: 500): retrying in 1m1s (49 left): timestamp=2024-08-05T02:08:39.585Z
module.<NAME>.azurerm_container_group.example: Still creating... [13m10s elapsed]
module.<NAME>.azurerm_container_group.example: Still creating... [13m20s elapsed]
...etc...

Expected Behaviour

Container to create with the setting from the example

Actual Behaviour

http/500 error from the API to terraform, until changed from value "0.5" to "1.0" and then it works

To determine the cause I tried a manual create in the UI with the original settings and that's when I noticed the value wasn't being accepted.

Steps to Reproduce

terraform apply

Important Factoids

N/A

References

N/A

magodo commented 3 months ago

@mattduguid As the Azure document mentioned about the minimum resource allocation:

Allocate a minimum of 1 CPU and 1 GB of memory to a container group. Individual container instances within a group can be provisioned with less than 1 CPU and 1 GB of memory

I've tried the following config locally, which can provision successfully:

resource "azurerm_container_group" "test" {
  name                = "acctestcontainergroup-333"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name
  ip_address_type     = "None"
  os_type             = "Linux"

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

You probably need to file an Azure support ticket with your request correlation id to figure out why you got that 500 status code.

mattduguid commented 3 months ago

@magodo thanks for checking that, we did have the same issue when trying via the portal UI, it might be something specific to our region/account/etc can log a ticket :)

github-actions[bot] commented 2 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.