Skip to content

Commit

Permalink
Merge pull request #1 from gauravnegi01/function-app
Browse files Browse the repository at this point in the history
 Azure Function app Terraform Module: Added features to setup  Azure Function app
  • Loading branch information
rahulttn authored Apr 8, 2024
2 parents 95c9206 + 5383392 commit 226d9d5
Show file tree
Hide file tree
Showing 15 changed files with 883 additions and 25 deletions.
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Local .terraform directories
**/.terraform/*

.terraform.lock.hcl

# .tfstate files
*.tfstate
*.tfstate.*
*.git
# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*


# Ignore environment files containing secrets for local execution of terraform
.env
# Ignore .vscode folder and all the consisting files
.vscode/

# Ignore .idea folder and all the consisting files
.idea/
8 changes: 8 additions & 0 deletions Example/basic_function_app/_backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# terraform {
# backend "azurerm" {
# resource_group_name = "rg_name"
# storage_account_name = "storage_account_name"
# container_name = "backend_container_name"
# key = "backend_key"
# }
# }
102 changes: 102 additions & 0 deletions Example/basic_function_app/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {}
}

resource "azurerm_storage_account" "storage_account" {
name = "terraformtesting0001112"
resource_group_name = "function-app-rg"
location = "Central India"
account_tier = "Standard"
account_replication_type = "GRS"
}

module "Azure_Function_App" {
source = "git::https://github.com/tothenew/azure-terraform-function.git"

# set the value of create_resource_group = false if you have a existing resource group then simply pass the name and location of resource group
create_resource_group = true
resource_group_name = "function-app-rg"
location = "Central India"

# if you don't have a existing storage account then use this configuration
create_storage_account = true
storage_name = azurerm_storage_account.storage_account.name
storage_account_access_key = azurerm_storage_account.storage_account.primary_access_key

# if you have a existing storage account then use this configuration
# create_storage_account = false
# storage_account_name = "terraformteststacc01"
# storage_account_resource_group_name = "gaurav"


################# App Service Plan #############################
service_plan_name = "app-service-plan-1"
os_type = "Linux"
sku_name = "B2"

#################### function App ###############################
function_apps = {
function_app-1 = {
name = "function-app-1000111"
location = "Central India"
public_network_access_enabled = true
functions_extension_version = "~4"
client_certificate_mode = null
client_certificate_enabled = null


site_config = {
always_on = true
http2_enabled = false
load_balancing_mode = "LeastRequests"
managed_pipeline_mode = "Integrated"
minimum_tls_version = "1.2"
remote_debugging_enabled = false
scm_minimum_tls_version = "1.2"
scm_use_main_ip_restriction = false
websockets_enabled = false
}
application_stack = {
python_version = "3.10"
}
app_service_logs = null
cors = null
ip_restriction = null
# function_app-2 = {
# name = "function-app-2"
# location = "Central India"
# public_network_access_enabled = true
# functions_extension_version = "~4"
# }
}
}
identity_type = "SystemAssigned"
#provide 'identity_ids' if identity_type is 'UserAssigned'
#identity_ids = null

default_tags = {
"Scope" : "function_app"
"CreatedBy" : "Terraform"
}

common_tags = {
Project = "Azure_Function_app",
Managed-By = "TTN",
}

project_name_prefix = "dev"
}

11 changes: 11 additions & 0 deletions Example/basic_function_app/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "linux_function_app_default_hostnames" {
description = "The Default Hostnames associated with the Azure Function Apps for Linux OS"
value = module.Azure_Function_App.linux_function_app_default_hostnames

}

output "windows_function_app_default_hostnames" {
description = "The Default Hostnames associated with the Azure Function Apps for winfow OS"
value = module.Azure_Function_App.windows_function_app_default_hostnames

}
8 changes: 8 additions & 0 deletions Example/complete_function_app/_backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# terraform {
# backend "azurerm" {
# resource_group_name = "rg_name"
# storage_account_name = "storage_account_name"
# container_name = "backend_container_name"
# key = "backend_key"
# }
# }
134 changes: 134 additions & 0 deletions Example/complete_function_app/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {}
}


resource "azurerm_storage_account" "storage_account" {
name = "terraformtesting0001112"
resource_group_name = "function-app-rg"
location = "Central India"
account_tier = "Standard"
account_replication_type = "GRS"

}

module "log_analytics" {
source = "git::https://github.com/tothenew/terraform-azure-loganalytics.git"
# source = "../.."

workspace_name = "function-app-log-analytics"
resource_group_name = "function-app-rg"
location = "Central India"
diagnostic_setting_name = "function-app-log-diagnostic-setting"
}

resource "azurerm_application_insights" "application_insights" {
name = "tf-test-appinsights"
location = "Central India"
resource_group_name = "function-app-rg"
workspace_id = module.log_analytics.workspace_id
application_type = "web"
}

module "Azure_Function_App" {
source = "git::https://github.com/tothenew/azure-terraform-function.git"

# set the value of create_resource_group = false if you have a existing resource group then simply pass the name and location of resource group
create_resource_group = true
resource_group_name = "function-app-rg"
location = "Central India"

# if you don't have a existing storage account then use this configuration
create_storage_account = true
storage_name = azurerm_storage_account.storage_account.name
storage_account_access_key = azurerm_storage_account.storage_account.primary_access_key

# if you have a existing storage account then use this configuration
# create_storage_account = false
# storage_account_name = "terraformteststacc01"
# storage_account_resource_group_name = "function-app-rg"



################# App Service Plan #############################
service_plan_name = "app-service-plan-1"
os_type = "Linux"
sku_name = "B2"

#################### function App ###############################
function_apps = {
function_app-1 = {
name = "function-app-1000111"
location = "Central India"
public_network_access_enabled = true
functions_extension_version = "~4"
client_certificate_mode = null
client_certificate_enabled = null


site_config = {
always_on = true
http2_enabled = false
load_balancing_mode = "LeastRequests"
managed_pipeline_mode = "Integrated"
minimum_tls_version = "1.2"
remote_debugging_enabled = false
scm_minimum_tls_version = "1.2"
scm_use_main_ip_restriction = false
websockets_enabled = false
application_insights_connection_string = azurerm_application_insights.application_insights.connection_string
application_insights_key = azurerm_application_insights.application_insights.instrumentation_key
}
application_stack = {
python_version = "3.10"
}
app_service_logs = null
cors = null
ip_restriction = {
action = "Allow"
name = "My IP Restriction"
priority = 100
ip_address = "192.168.1.1/32"
service_tag = null
headers = null
virtual_network_subnet_id = null
}
# function_app-2 = {
# name = "function-app-2"
# location = "Central India"
# public_network_access_enabled = true
# functions_extension_version = "~4"
# }
}
}
identity_type = "SystemAssigned"
#provide 'identity_ids' if identity_type is 'UserAssigned'
#identity_ids = null

default_tags = {
"Scope" : "function_app"
"CreatedBy" : "Terraform"
}

common_tags = {
Project = "Azure_Function_app",
Managed-By = "TTN",
}

project_name_prefix = "dev"

}

11 changes: 11 additions & 0 deletions Example/complete_function_app/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "linux_function_app_default_hostnames" {
description = "The Default Hostnames associated with the Azure Function Apps for Linux OS"
value = module.Azure_Function_App.linux_function_app_default_hostnames

}

output "windows_function_app_default_hostnames" {
description = "The Default Hostnames associated with the Azure Function Apps for winfow OS"
value = module.Azure_Function_App.windows_function_app_default_hostnames

}
Loading

0 comments on commit 226d9d5

Please sign in to comment.