Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


Terraform AzureRM - azurerm_service_plan

Guide to managing Azure App Service Plans using Terraform.

Prerequisite

If you need to install The azurerm Terraform provider, follow:

Declare App Service Plan

Resource Block

The local name will need setting.

resource "azurerm_service_plan" "<local name>" {
}

Required Arguments

The required arguments are:

name

The name of the App Service Plan.

name = "asp-<project, app or service>-<environment>-<###>"

Changing this argument will recreate the resource.

location

Specifies the location of the resource.

location = "uksouth"

To list all locations, you can run:

Get-AzLocation | select-object location

Changing this argument will recreate the resource.

os_type

Specifies the Operating Systems the plan will host.

Valid options are:

  • Linux
  • Windows
  • WindowsContainer
os_type = "Linux"

Changing this argument will recreate the resource.

resource_group_name

Specifies the resource group the App Service Plan should reside in.

resource_group_name = azurerm_resource_group.<local name>.name

Changing this argument will recreate the resource.

sku_name

The SKU to use for the App Service Plan.

Valid options are:

B1, B2, B3, D1, F1, FREE, I1, I1v2, I2, I2v2, I3, I3v2, I4v2, I5v2, I6v2, P0V3, P1MV3, P1V2, P1V3, P2MV3, P2V2, P2V3, P3MV3, P3V2, P3V3, P4MV3, P5MV3, S1, S2, S3, SHARED, WS1, WS2, WS3.

Valid options at the time of writing. Visit az appservice plan to check for any updates.

Optional Arguments

Some optional arguments are:

worker_count

Specifies the number of instances you App Service Plan can run.

worker_count = 1

tags

Set as many key value pairs that you need.

tags = {
  environment = "demo"
  source      = "terraform"
}

Example Declaration

This is an example for declaring an App Service Plan:

resource "azurerm_service_plan" "asp-dtvlinux-001" {
  name                = "asp-dtvlinux-demo-001"
  resource_group_name = "rg-webapp-demo-001"
  location            = "westus2"
  os_type             = "Linux"
  sku_name            = "B1"
  tags                = {
    environment = "demo"
    source      = "terraform"
  }
}

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.