0

I am working on Terraform script for Azure. Currently App Service Plan is declared as data. Now i need to add Scaleout Rules. Should i create App Service Plan as data or convert it to 'resource' and add scaleout rules?

data "azurerm_app_service_plan" "example" {
  name = "search-app-service-plan"
  resource_group_name = "search-service"
}
Marko E
  • 13,362
  • 2
  • 19
  • 28
JemHah
  • 434
  • 4
  • 16
  • You don’t need to try any of the above methods. Use `terraform import` to import the `app service Plan` resource into the state file & then change it in the way you want. – harshavmb Jul 13 '22 at 06:41
  • App Service Plan was create through Terraform only so 'data' is declared – JemHah Jul 13 '22 at 07:33
  • Please add the code you are currently using, without it it's only guesswork. – Marko E Jul 13 '22 at 08:08
  • refer link: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/app_service_plan data "azurerm_app_service_plan" "example" { name = "search-app-service-plan" resource_group_name = "search-service" } this is how App service plan is defined in my terraform code currently – JemHah Jul 13 '22 at 08:39
  • That's all the code you have? – Marko E Jul 13 '22 at 08:52
  • "convert it to 'resource' and add scaleout rules" yes, and you would also need to import it after declaring. Note that https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan does not seem to have an argument or block for adding scaleout rules though. – Matthew Schuchard Jul 13 '22 at 11:07
  • Could you please refer this [SO THREAD](https://stackoverflow.com/questions/58039351/update-existing-app-service-with-terraform) – AjayKumarGhose Jul 13 '22 at 11:41

1 Answers1

1

data is added to access information about an existing resource.

In case your app service plan resource is not created via terraform, you need to import existing infrastructure. This allows you take resources you've created by some other means and bring it under Terraform management.

And then you can just add the resource app service block with everything you needed including the scale out rules and running script then would be ok.

simmyk
  • 26
  • 4