Skip to content

azurermServicePlan

Manages an App Service: Service Plan.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.provider.AzurermProvider(this, "azurerm", {
  features: [{}],
});
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermServicePlanExample = new azurerm.servicePlan.ServicePlan(
  this,
  "example_2",
  {
    location: azurermResourceGroupExample.location,
    name: "example",
    os_type: "Linux",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "P1v2",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermServicePlanExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this Service Plan. Changing this forces a new AppService to be created.

  • location - (Required) The Azure Region where the Service Plan should exist. Changing this forces a new AppService to be created.

  • osType - (Required) The O/S type for the App Services to be hosted in this plan. Possible values include windows, linux, and windowsContainer. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the Resource Group where the AppService should exist. Changing this forces a new AppService to be created.

  • skuName - (Required) The SKU for the plan. Possible values include b1, b2, b3, d1, f1, i1, i2, i3, i1V2, i2V2, i3V2, p1V2, p2V2, p3V2, p1V3, p2V3, p3V3, s1, s2, s3, shared, ep1, ep2, ep3, ws1, ws2, ws3, and y1.

\~> NOTE: Isolated SKUs (i1, i2, i3, i1V2, i2V2, and i3V2) can only be used with App Service Environments

\~> NOTE: Elastic and Consumption SKUs (y1, ep1, ep2, and ep3) are for use with Function Apps.


  • appServiceEnvironmentId - (Optional) The ID of the App Service Environment to create this Service Plan in.

\~> NOTE: Requires an Isolated SKU. Use one of i1, i2, i3 for azurermAppServiceEnvironment, or i1V2, i2V2, i3V2 for azurermAppServiceEnvironmentV3

  • maximumElasticWorkerCount - (Optional) The maximum number of workers to use in an Elastic SKU Plan. Cannot be set unless using an Elastic SKU.

  • workerCount - (Optional) The number of Workers (instances) to be allocated.

  • perSiteScalingEnabled - (Optional) Should Per Site Scaling be enabled. Defaults to false.

  • zoneBalancingEnabled - (Optional) Should the Service Plan balance across Availability Zones in the region. Changing this forces a new resource to be created.

\~> NOTE: If this setting is set to true and the workerCount value is specified, it should be set to a multiple of the number of availability zones in the region. Please see the Azure documentation for the number of Availability Zones in your region.

  • tags - (Optional) A mapping of tags which should be assigned to the AppService.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Service Plan.

  • kind - A string representing the Kind of Service Plan.

  • reserved - Whether this is a reserved Service Plan Type. true if osType is linux, otherwise false.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 1 hour) Used when creating the Service Plan.
  • read - (Defaults to 5 minutes) Used when retrieving the Service Plan.
  • update - (Defaults to 1 hour) Used when updating the Service Plan.
  • delete - (Defaults to 1 hour) Used when deleting the Service Plan.

Import

AppServices can be imported using the resourceId, e.g.

terraform import azurerm_service_plan.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/serverfarms/farm1