Skip to content

Commit e4e9e52

Browse files
authored
Merge pull request #1 from data-platform-hq/add-module
feat: add module
2 parents 6553139 + 9194ada commit e4e9e52

File tree

5 files changed

+217
-3
lines changed

5 files changed

+217
-3
lines changed

README.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,60 @@
1-
# Azure <> Terraform module
2-
Terraform module for creation Azure <>
1+
# Azure Linux Web App Terraform module
2+
Terraform module for creation Azure Linux Web App
33

44
## Usage
55

66
<!-- BEGIN_TF_DOCS -->
7+
## Requirements
78

9+
| Name | Version |
10+
|------|---------|
11+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
12+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.23.0 |
13+
14+
## Providers
15+
16+
| Name | Version |
17+
|------|---------|
18+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.27.0 |
19+
20+
## Modules
21+
22+
No modules.
23+
24+
## Resources
25+
26+
| Name | Type |
27+
|------|------|
28+
| [azurerm_app_service_virtual_network_swift_connection.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_virtual_network_swift_connection) | resource |
29+
| [azurerm_application_insights.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights) | resource |
30+
| [azurerm_linux_web_app.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app) | resource |
31+
32+
## Inputs
33+
34+
| Name | Description | Type | Default | Required |
35+
|------|-------------|------|---------|:--------:|
36+
| <a name="input_app_settings"></a> [app\_settings](#input\_app\_settings) | Application setting | `map(string)` | `{}` | no |
37+
| <a name="input_application_type"></a> [application\_type](#input\_application\_type) | Application type (java, python, etc) | `string` | `"java"` | no |
38+
| <a name="input_env"></a> [env](#input\_env) | Environment | `string` | n/a | yes |
39+
| <a name="input_ip_restriction"></a> [ip\_restriction](#input\_ip\_restriction) | Firewall settings for the function app | <pre>list(object({<br> name = string<br> ip_address = string<br> service_tag = string<br> virtual_network_subnet_id = string<br> priority = string<br> action = string<br> headers = list(object({<br> x_azure_fdid = list(string)<br> x_fd_health_probe = list(string)<br> x_forwarded_for = list(string)<br> x_forwarded_host = list(string)<br> }))<br> }))</pre> | <pre>[<br> {<br> "action": "Allow",<br> "headers": null,<br> "ip_address": null,<br> "name": "allow_azure",<br> "priority": "100",<br> "service_tag": "AzureCloud",<br> "virtual_network_subnet_id": null<br> }<br>]</pre> | no |
40+
| <a name="input_java_version"></a> [java\_version](#input\_java\_version) | Java version | `string` | `"8"` | no |
41+
| <a name="input_location"></a> [location](#input\_location) | Location | `string` | n/a | yes |
42+
| <a name="input_name"></a> [name](#input\_name) | Function index/name (like 007) | `string` | n/a | yes |
43+
| <a name="input_project"></a> [project](#input\_project) | Project name | `string` | n/a | yes |
44+
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | Resource group name | `string` | n/a | yes |
45+
| <a name="input_service_plan_id"></a> [service\_plan\_id](#input\_service\_plan\_id) | App Service plan ID | `string` | n/a | yes |
46+
| <a name="input_subnet_id"></a> [subnet\_id](#input\_subnet\_id) | Subnet ID for the function app | `string` | `null` | no |
47+
| <a name="input_tags"></a> [tags](#input\_tags) | Tags | `map(string)` | n/a | yes |
48+
| <a name="input_use_private_net"></a> [use\_private\_net](#input\_use\_private\_net) | Use private network injection | `bool` | `false` | no |
49+
50+
## Outputs
51+
52+
| Name | Description |
53+
|------|-------------|
54+
| <a name="output_id"></a> [id](#output\_id) | Linux Web App ID |
55+
| <a name="output_identity"></a> [identity](#output\_identity) | Function app Managed Identity |
856
<!-- END_TF_DOCS -->
957

1058
## License
1159

12-
Apache 2 Licensed. For more information please see [LICENSE](https://github.com/data-platform-hq/terraform-azurerm<>/tree/master/LICENSE)
60+
Apache 2 Licensed. For more information please see [LICENSE](https://github.com/data-platform-hq/terraform-azurerm-linux-web-app/tree/main/LICENSE)

main.tf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
resource "azurerm_application_insights" "this" {
2+
name = "fn-${var.project}-${var.env}-${var.location}-${var.name}"
3+
location = var.location
4+
resource_group_name = var.resource_group
5+
application_type = var.application_type
6+
tags = var.tags
7+
}
8+
9+
locals {
10+
app_settings = {
11+
WEBSITES_ENABLE_APP_SERVICE_STORAGE = "true"
12+
WEBSITE_ENABLE_SYNC_UPDATE_SITE = "true"
13+
JAVA_OPTS = "-Dlog4j2.formatMsgNoLookups=true"
14+
LOG4J_FORMAT_MSG_NO_LOOKUPS = "true"
15+
WEBSITE_USE_PLACEHOLDER = "0"
16+
AZURE_LOG_LEVEL = "info"
17+
APPINSIGHTS_INSTRUMENTATIONKEY = azurerm_application_insights.this.instrumentation_key
18+
}
19+
}
20+
21+
resource "azurerm_linux_web_app" "this" {
22+
depends_on = [azurerm_application_insights.this]
23+
name = "web-${var.project}-${var.env}-${var.location}-${var.name}"
24+
location = var.location
25+
resource_group_name = var.resource_group
26+
service_plan_id = var.service_plan_id
27+
https_only = true
28+
enabled = true
29+
tags = var.tags
30+
app_settings = merge(local.app_settings, var.app_settings)
31+
32+
identity {
33+
type = "SystemAssigned"
34+
}
35+
site_config {
36+
always_on = true
37+
ftps_state = "Disabled"
38+
http2_enabled = true
39+
websockets_enabled = false
40+
use_32_bit_worker = false
41+
ip_restriction = var.ip_restriction
42+
scm_ip_restriction = var.ip_restriction
43+
application_stack {
44+
java_version = var.java_version
45+
}
46+
}
47+
}
48+
49+
resource "azurerm_app_service_virtual_network_swift_connection" "this" {
50+
count = var.use_private_net == null ? 0 : 1
51+
app_service_id = azurerm_linux_web_app.this.id
52+
subnet_id = var.subnet_id
53+
}

outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "id" {
2+
value = azurerm_linux_web_app.this.id
3+
description = "Linux Web App ID"
4+
}
5+
6+
output "identity" {
7+
value = azurerm_linux_web_app.this.identity.*
8+
description = "Function app Managed Identity"
9+
}

variables.tf

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
variable "project" {
2+
type = string
3+
description = "Project name"
4+
}
5+
6+
variable "env" {
7+
type = string
8+
description = "Environment"
9+
}
10+
11+
variable "location" {
12+
type = string
13+
description = "Location"
14+
}
15+
16+
variable "tags" {
17+
type = map(string)
18+
description = "Tags"
19+
}
20+
21+
variable "resource_group" {
22+
type = string
23+
description = "Resource group name"
24+
}
25+
26+
27+
variable "service_plan_id" {
28+
type = string
29+
description = "App Service plan ID"
30+
}
31+
32+
variable "name" {
33+
type = string
34+
description = "Function index/name (like 007)"
35+
}
36+
37+
variable "application_type" {
38+
type = string
39+
description = "Application type (java, python, etc)"
40+
default = "java"
41+
}
42+
43+
variable "java_version" {
44+
type = string
45+
description = "Java version"
46+
default = "8"
47+
}
48+
49+
variable "ip_restriction" {
50+
description = "Firewall settings for the function app"
51+
type = list(object({
52+
name = string
53+
ip_address = string
54+
service_tag = string
55+
virtual_network_subnet_id = string
56+
priority = string
57+
action = string
58+
headers = list(object({
59+
x_azure_fdid = list(string)
60+
x_fd_health_probe = list(string)
61+
x_forwarded_for = list(string)
62+
x_forwarded_host = list(string)
63+
}))
64+
}))
65+
default = [
66+
{
67+
name = "allow_azure"
68+
ip_address = null
69+
service_tag = "AzureCloud"
70+
virtual_network_subnet_id = null
71+
priority = "100"
72+
action = "Allow"
73+
headers = null
74+
}
75+
]
76+
}
77+
78+
variable "app_settings" {
79+
type = map(string)
80+
default = {}
81+
description = "Application setting"
82+
}
83+
84+
variable "subnet_id" {
85+
type = string
86+
description = "Subnet ID for the function app"
87+
default = null
88+
}
89+
90+
variable "use_private_net" {
91+
type = bool
92+
description = "Use private network injection"
93+
default = false
94+
}

versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0.0"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = ">= 3.23.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)