microsoft / azure-redcap-paas

Automated deployment of REDCap with Azure Blob storage as the storage back-end
MIT License
28 stars 53 forks source link

Terraform: Update deprecated azurerm_app_service_plan resource to azurerm_service_plan #54

Open epopisces opened 8 months ago

epopisces commented 8 months ago

azurerm_app_service_plan is deprecated in version 3.x of the azurerm provider. The recommended guidance is to use the new azurerm_service_plan resource. Fortunately the update is relatively straightforward.

# the existing:
resource "azurerm_app_service_plan" "redcap" {
  name                = "${local.app_service_name}Plan"
  resource_group_name = azurerm_resource_group.redcap.name
  location            = azurerm_resource_group.redcap.location
  tags                = var.tags
  kind                = "Linux"
  reserved            = true

  sku {
    tier     = var.app_service_plan_tier
    size     = var.app_service_plan_size
    capacity = var.skuCapacity
  }
}

# becomes: 
resource "azurerm_service_plan" "redcap" {
  name                = "${local.app_service_name}Plan"
  resource_group_name = azurerm_resource_group.redcap.name
  location            = azurerm_resource_group.redcap.location
  os_type             = "Linux"
  sku_name            = var.app_service_plan_size
}

The app_service_plan_tier and skuCapacity arguments can then be removed.

Any existing projects updating from the one resource to the other will need to use terraform state move or terraform import to bring the existing resource under management of the new resource.