cleaning up
This commit is contained in:
parent
d9ceb6ca3d
commit
6b5c659496
@ -10,7 +10,6 @@ This template deploys an Azure Function App.
|
|||||||
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
||||||
- [azurerm_service_plan](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan)
|
- [azurerm_service_plan](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan)
|
||||||
- [azurerm_function_app](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app)
|
- [azurerm_function_app](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app)
|
||||||
- [azurerm_application_insights](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights)
|
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
@ -18,7 +17,11 @@ This template deploys an Azure Function App.
|
|||||||
|-|-|-|
|
|-|-|-|
|
||||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||||
| `resource_group_location` | Location of the resource group. | eastus |
|
| `resource_group_location` | Location of the resource group. | eastus |
|
||||||
| `appName` | The name of the function app that you wish to create. | fnapp${random_string.unique_id.result} |
|
| `sa_account_tier` | The tier of the storage account. Possible values are Standard and Premium. | "Standard" |
|
||||||
| `runtime` | The language worker runtime to load in the function app. Possible values are: node, dotnet, java. | node |
|
| `sa_account_replication_type` | The replication type of the storage account. Possible values are LRS, GRS, RAGRS, and ZRS. | "LRS" |
|
||||||
|
| `sa_name` | The name of the storage account. | Randomly generated |
|
||||||
|
| `asp_name` | The name of the App Service Plan. | Randomly generated |
|
||||||
|
| `asp_sku_tier` | The SKU tier of the App Service Plan. Possible values are Free, Shared, Basic, Standard, Premium, PremiumV2, and PremiumV3. | "Standard" |
|
||||||
|
| `fa_name` | The name of the Function App." | Randomly generated |
|
||||||
|
|
||||||
## Example
|
## Example
|
@ -1,32 +1,44 @@
|
|||||||
resource "azurerm_resource_group" "az_rg" {
|
resource "random_pet" "rg_name" {
|
||||||
name = var.az_rg_name
|
prefix = var.resource_group_name_prefix
|
||||||
location = var.location
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "azurerm_storage_account" "az_sa" {
|
resource "azurerm_resource_group" "rg" {
|
||||||
name = var.az_sa_name
|
location = var.resource_group_location
|
||||||
resource_group_name = azurerm_resource_group.az_rg.name
|
name = coalesce(var.resource_group_name, random_pet.rg_name.id)
|
||||||
location = azurerm_resource_group.az_rg.location
|
|
||||||
account_tier = var.az_sa_account_tier
|
|
||||||
account_replication_type = var.az_sa_account_replication_type
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "azurerm_app_service_plan" "az_asp" {
|
resource "random_string" "name" {
|
||||||
name = var.az_asp_name
|
length = 13
|
||||||
location = azurerm_resource_group.az_rg.location
|
lower = true
|
||||||
resource_group_name = azurerm_resource_group.az_rg.name
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_storage_account" "example" {
|
||||||
|
name = coalesce(var.sa_name, "sa${random_string.name.result}")
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
account_tier = var.sa_account_tier
|
||||||
|
account_replication_type = var.sa_account_replication_type
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_app_service_plan" "example" {
|
||||||
|
name = coalesce(var.asp_name, "sp${random_string.name.result}")
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
|
||||||
sku {
|
sku {
|
||||||
tier = var.az_asp_sku_tier
|
tier = var.asp_sku_tier
|
||||||
size = "S1"
|
size = "S1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "azurerm_function_app" "az_fa" {
|
resource "azurerm_function_app" "example" {
|
||||||
name = var.az_fa_name
|
name = coalesce(var.fa_name, "fa${random_string.name.result}")
|
||||||
location = azurerm_resource_group.az_rg.location
|
location = azurerm_resource_group.rg.location
|
||||||
resource_group_name = azurerm_resource_group.az_rg.name
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
app_service_plan_id = azurerm_app_service_plan.az_asp.id
|
app_service_plan_id = azurerm_app_service_plan.example.id
|
||||||
storage_account_name = azurerm_storage_account.az_sa.name
|
storage_account_name = azurerm_storage_account.example.name
|
||||||
storage_account_access_key = azurerm_storage_account.az_sa.primary_access_key
|
storage_account_access_key = azurerm_storage_account.example.primary_access_key
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,53 @@
|
|||||||
variable "az_rg_name" {
|
variable "resource_group_name" {
|
||||||
type = string
|
type = string
|
||||||
default = "azure-functions-example-rg"
|
default = ""
|
||||||
|
description = "The name of the Azure resource group. If blank, a random name will be generated."
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "location" {
|
variable "resource_group_name_prefix" {
|
||||||
type = string
|
type = string
|
||||||
default = "East US"
|
default = "rg"
|
||||||
|
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "az_sa_account_tier" {
|
variable "resource_group_location" {
|
||||||
type = string
|
type = string
|
||||||
default = "Standard"
|
default = "eastus"
|
||||||
|
description = "Location of the resource group."
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "az_sa_account_replication_type" {
|
variable "sa_account_tier" {
|
||||||
type = string
|
description = "The tier of the storage account. Possible values are Standard and Premium."
|
||||||
default = "LRS"
|
type = string
|
||||||
|
default = "Standard"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "az_sa_name" {
|
variable "sa_account_replication_type" {
|
||||||
type = string
|
description = "The replication type of the storage account. Possible values are LRS, GRS, RAGRS, and ZRS."
|
||||||
default = "examplefunctionssa"
|
type = string
|
||||||
|
default = "LRS"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "az_asp_name" {
|
variable "sa_name" {
|
||||||
type = string
|
description = "The name of the storage account. If blank, a random name will be generated."
|
||||||
default = "example-functions-service-plan"
|
type = string
|
||||||
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "az_asp_sku_tier" {
|
variable "asp_name" {
|
||||||
type = string
|
description = "The name of the App Service Plan. If blank, a random name will be generated."
|
||||||
default = "Standard"
|
type = string
|
||||||
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "az_fa_name" {
|
variable "asp_sku_tier" {
|
||||||
type = string
|
description = "The SKU tier of the App Service Plan. Possible values are Free, Shared, Basic, Standard, Premium, PremiumV2, and PremiumV3."
|
||||||
default = "example-functions-app"
|
type = string
|
||||||
|
default = "Standard"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "fa_name" {
|
||||||
|
description = "The name of the Function App. If blank, a random name will be generated."
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user