cleaning up
This commit is contained in:
parent
19fb9b1d52
commit
a75d5d0f91
@ -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_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_application_insights](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights)
|
||||
|
||||
## 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_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} |
|
||||
| `runtime` | The language worker runtime to load in the function app. Possible values are: node, dotnet, java. | node |
|
||||
| `sa_account_tier` | The tier of the storage account. Possible values are Standard and Premium. | "Standard" |
|
||||
| `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
|
@ -1,32 +1,44 @@
|
||||
resource "azurerm_resource_group" "az_rg" {
|
||||
name = var.az_rg_name
|
||||
location = var.location
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_storage_account" "az_sa" {
|
||||
name = var.az_sa_name
|
||||
resource_group_name = azurerm_resource_group.az_rg.name
|
||||
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_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = coalesce(var.resource_group_name, random_pet.rg_name.id)
|
||||
}
|
||||
|
||||
resource "azurerm_app_service_plan" "az_asp" {
|
||||
name = var.az_asp_name
|
||||
location = azurerm_resource_group.az_rg.location
|
||||
resource_group_name = azurerm_resource_group.az_rg.name
|
||||
resource "random_string" "name" {
|
||||
length = 13
|
||||
lower = true
|
||||
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 {
|
||||
tier = var.az_asp_sku_tier
|
||||
tier = var.asp_sku_tier
|
||||
size = "S1"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_function_app" "az_fa" {
|
||||
name = var.az_fa_name
|
||||
location = azurerm_resource_group.az_rg.location
|
||||
resource_group_name = azurerm_resource_group.az_rg.name
|
||||
app_service_plan_id = azurerm_app_service_plan.az_asp.id
|
||||
storage_account_name = azurerm_storage_account.az_sa.name
|
||||
storage_account_access_key = azurerm_storage_account.az_sa.primary_access_key
|
||||
resource "azurerm_function_app" "example" {
|
||||
name = coalesce(var.fa_name, "fa${random_string.name.result}")
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
app_service_plan_id = azurerm_app_service_plan.example.id
|
||||
storage_account_name = azurerm_storage_account.example.name
|
||||
storage_account_access_key = azurerm_storage_account.example.primary_access_key
|
||||
}
|
||||
|
@ -1,40 +1,53 @@
|
||||
variable "az_rg_name" {
|
||||
type = string
|
||||
default = "azure-functions-example-rg"
|
||||
variable "resource_group_name" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The name of the Azure resource group. If blank, a random name will be generated."
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
type = string
|
||||
default = "East US"
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
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" {
|
||||
type = string
|
||||
default = "Standard"
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "az_sa_account_replication_type" {
|
||||
type = string
|
||||
default = "LRS"
|
||||
variable "sa_account_tier" {
|
||||
description = "The tier of the storage account. Possible values are Standard and Premium."
|
||||
type = string
|
||||
default = "Standard"
|
||||
}
|
||||
|
||||
variable "az_sa_name" {
|
||||
type = string
|
||||
default = "examplefunctionssa"
|
||||
variable "sa_account_replication_type" {
|
||||
description = "The replication type of the storage account. Possible values are LRS, GRS, RAGRS, and ZRS."
|
||||
type = string
|
||||
default = "LRS"
|
||||
}
|
||||
|
||||
variable "az_asp_name" {
|
||||
type = string
|
||||
default = "example-functions-service-plan"
|
||||
variable "sa_name" {
|
||||
description = "The name of the storage account. If blank, a random name will be generated."
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "az_asp_sku_tier" {
|
||||
type = string
|
||||
default = "Standard"
|
||||
variable "asp_name" {
|
||||
description = "The name of the App Service Plan. If blank, a random name will be generated."
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "az_fa_name" {
|
||||
type = string
|
||||
default = "example-functions-app"
|
||||
variable "asp_sku_tier" {
|
||||
description = "The SKU tier of the App Service Plan. Possible values are Free, Shared, Basic, Standard, Premium, PremiumV2, and PremiumV3."
|
||||
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