Home > Back-end >  How to push a docker image to azure app service using terraform?
How to push a docker image to azure app service using terraform?

Time:09-05

I'm creating an azure web app for containers with terraform but keep receiving this error

here's my code:

resource "azurerm_service_plan" "myApp-plan" {
  name                = "myApp-plan"
  location            = "${azurerm_resource_group.myResourceGroup.location}"
  resource_group_name = "${azurerm_resource_group.myResourceGroup.name}"
  os_type             = "Linux"
  sku_name            = "S2"
}

resource "azurerm_linux_web_app" "myApp" {
  name                = "myApp"
  resource_group_name = "${azurerm_resource_group.myResourceGroup.name}"
  location            = "${azurerm_resource_group.myResourceGroup.location}"
  service_plan_id     = "${azurerm_service_plan.myApp-plan.id}"

  https_only            = true

  app_settings = {} #some env variables
    
  site_config { 
    minimum_tls_version  = "1.2"
    linux_fx_version     = "DOCKER|jboss/keycloak:11.0.0"
  }

}

when I run terraform apply I receive this:

│ Error: Value for unconfigurable attribute
│
│   with azurerm_linux_web_app.keycloak_app,
│   on main.tf line 98, in resource "azurerm_linux_web_app" "myApp":
│   98:     linux_fx_version     = "DOCKER|jboss/keycloak:11.0.0"
│
│ Can't configure a value for "site_config.0.linux_fx_version": its value will be decided automatically based on the result of applying this configuration.

Any advice pls?

CodePudding user response:

If you're pinned to version 2.0 I cannot see any documentation for the resource named azurerm_linux_web_app. I do see azurerm_app_service though.

It looks like the argument you're trying to set is here

Based on the documentation, you will need to call your resource azurerm_app_service and use the version 2.0 of the provider. There may be other attributes you need to adjust so please check the correct documentation version.

You may have been referring to the latest version documentation which has a resource named azurerm_linux_web_app and a site_config block that doesn't support a user specified linux_fx_version argument.

  • Related