Adding guidance for function app (#116)

* adding guidance for function app
This commit is contained in:
Xiaxin 2022-11-16 13:56:21 +08:00 committed by GitHub
parent 329bfd1f6e
commit e32966e242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 193 additions and 0 deletions

View File

@ -0,0 +1,11 @@
formatter: "markdown table"
content: |-
{{ .Resources }}
{{ .Inputs }}
{{ .Providers }}
{{ .Requirements }}
output:
file: readme.html.markdown
mode: inject

View File

@ -0,0 +1,71 @@
/*
THIS FILE IS GENERATED BY TFMOD-SCAFFOLD, PLEASE DO NOT MODIFY IT.
IF YOU WANT TO USE A CUSTOMIZED CONFIGURATION, PLEASE CREATE YOUR OWN AND
SET THIS FILE'S PATH TO $TFLINT_CONFIG ENVVIRONMENT VARIABLE.
*/
plugin "azurerm" {
enabled = true
version = "0.18.0"
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}
rule "terraform_comment_syntax" {
enabled = true
}
rule "terraform_deprecated_index" {
enabled = true
}
rule "terraform_deprecated_interpolation" {
enabled = true
}
rule "terraform_documented_outputs" {
enabled = true
}
rule "terraform_documented_variables" {
enabled = true
}
rule "terraform_module_pinned_source" {
enabled = true
}
rule "terraform_module_version" {
enabled = true
}
rule "terraform_naming_convention" {
enabled = true
}
rule "terraform_required_providers" {
enabled = true
}
rule "terraform_required_version" {
enabled = true
}
rule "terraform_standard_module_structure" {
enabled = false
}
rule "terraform_typed_variables" {
enabled = true
}
rule "terraform_unused_declarations" {
enabled = true
}
rule "terraform_unused_required_providers" {
enabled = true
}
rule "terraform_workspace_remote" {
enabled = true
}

View File

@ -0,0 +1,47 @@
resource "azurerm_resource_group" "default" {
name = "${var.name_prefix}-rg"
location = var.location
}
resource "azurerm_storage_account" "default" {
name = "${var.name_prefix}sa"
resource_group_name = azurerm_resource_group.default.name
location = azurerm_resource_group.default.location
account_tier = "Standard"
account_replication_type = "LRS"
min_tls_version = "TLS1_2"
}
resource "azurerm_service_plan" "default" {
name = "${var.name_prefix}-sap"
location = azurerm_resource_group.default.location
resource_group_name = azurerm_resource_group.default.name
sku_name = "Y1"
os_type = "Linux"
}
# please note:
# You may see custom (~4) is set to the app's runtime version, along with a warning says Your app is pinned to an unsupported runtime version for dotnet. For better performance, we recommend using one of our supported versions instead: xxx.. This is because azure function v4 runtime requires .NET6.0 but the default value is 4.0. You need to set the .netframeworkversion to v6.0 to support azure funtion v4.
# If you would like to set the function runtime version, please use functions_extension_version property, terraform will set the FUNCTIONS_EXTENSION_VERSION in app_setting block, you don't need to specify the key in app_setting block.
# If you would like to set the required number of failed requests for an instance to be deemed unhealthy and removed from the load balancer under health check feature, using health_check_eviction_time_in_min property under site_config block. Terraform will set the key WEBSITE_HEALTHCHECK_MAXPINGFAILURES
# in app_setting for you.
resource "azurerm_linux_function_app" "test" {
name = "${var.name_prefix}-lfa"
location = azurerm_resource_group.default.location
resource_group_name = azurerm_resource_group.default.name
service_plan_id = azurerm_service_plan.default.id
storage_account_name = azurerm_storage_account.default.name
storage_account_access_key = azurerm_storage_account.default.primary_access_key
https_only = true
builtin_logging_enabled = false
functions_extension_version = "~4"
site_config {
application_stack {
dotnet_version = "6.0"
}
}
}

View File

@ -0,0 +1,13 @@
terraform {
required_version = ">=1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.8"
}
}
}
provider "azurerm" {
features {}
}

View File

@ -0,0 +1,41 @@
# Azure Windows/ Linux Function App.
This template deploys an Azure Function App.
<!-- Run the following commands on your Windows machine to update document -->
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest terraform-docs markdown table --output-file readme.html.markdown --output-mode inject ./ -->
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest markdown-table-formatter readme.html.markdown -->
<!-- Run the following command to lint Terraform code with tflint -->
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest tflint --config=.tflint.hcl -->
<!-- Run the following command to lint Terraform code with Checkov -->
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest checkov --skip-framework dockerfile --quiet -d ./ -->
<!-- -->
<!-- BEGIN_TF_DOCS -->
## Resources
| Name | Type |
|---------------------------------------------------------------------------------------------------------------------------------------|----------|
| [azurerm_linux_function_app.test](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app) | resource |
| [azurerm_resource_group.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_service_plan.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) | resource |
| [azurerm_storage_account.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) | resource |
## Inputs
| Name | Description | Type | Default | Required |
|-----------------------------------------------------------------------|---------------------------------------|----------|---------------|:--------:|
| <a name="input_location"></a> [location](#input\_location) | Location to deploy the resource group | `string` | `"West US 2"` | no |
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Prefix of the resource name | `string` | n/a | yes |
## Providers
| Name | Version |
|---------------------------------------------------------------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | ~>3.8 |
## Requirements
| Name | Version |
|---------------------------------------------------------------------------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~>3.8 |
<!-- END_TF_DOCS -->
## Example
To see how to run this example, see [Create an Azure Function App using Terraform](https://docs.microsoft.com/azure/developer/terraform/create-azure-function-app).

View File

@ -0,0 +1,10 @@
variable "name_prefix" {
type = string
description = "Prefix of the resource name"
}
variable "location" {
type = string
description = "Location to deploy the resource group"
default = "West US 2"
}