Skip to content

Commit 98b74c8

Browse files
authored
Merge pull request #1 from kumarvna/develop
Initial version PR
2 parents a69f9d9 + a3d952a commit 98b74c8

File tree

14 files changed

+2595
-2
lines changed

14 files changed

+2595
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
*.terraform.lock.hcl
78

89
# Crash log files
910
crash.log

README.md

Lines changed: 398 additions & 2 deletions
Large diffs are not rendered by default.

appinsights.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
data "azurerm_application_insights" "main" {
2+
count = var.application_insights_enabled && var.application_insights_id != null ? 1 : 0
3+
name = split("/", var.application_insights_id)[8]
4+
resource_group_name = split("/", var.application_insights_id)[4]
5+
}
6+
7+
resource "azurerm_application_insights" "main" {
8+
count = var.application_insights_enabled && var.application_insights_id == null ? 1 : 0
9+
name = lower(format("appi-%s", var.app_insights_name))
10+
location = local.location
11+
resource_group_name = local.resource_group_name
12+
application_type = var.application_insights_type
13+
retention_in_days = var.retention_in_days
14+
disable_ip_masking = var.disable_ip_masking
15+
tags = merge({ "ResourceName" = "${var.app_insights_name}" }, var.tags, )
16+
}

examples/complete/README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Azure App Service (Web Apps) Terraform Module
2+
3+
Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points.
4+
5+
## Module Usage
6+
7+
```hcl
8+
module "web-app" {
9+
source = "kumarvna/web-app/azurerm"
10+
version = "1.0.0"
11+
12+
# By default, this module will not create a resource group. Location will be same as existing RG.
13+
# proivde a name to use an existing resource group, specify the existing resource group name,
14+
# set the argument to `create_resource_group = true` to create new resrouce group.
15+
resource_group_name = "rg-shared-westeurope-01"
16+
17+
# App service plan setttings and supported arguments. Default name used by module
18+
# To specify custom name use `app_service_plan_name` with a valid name.
19+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
20+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
21+
service_plan = {
22+
kind = "Windows"
23+
size = "P1v2"
24+
tier = "PremiumV2"
25+
}
26+
27+
# App Service settings and supported arguments
28+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
29+
app_service_name = "mypocproject"
30+
enable_client_affinity = true
31+
32+
# A `site_config` block to setup the application environment.
33+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
34+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
35+
site_config = {
36+
always_on = true
37+
dotnet_framework_version = "v2.0"
38+
ftps_state = "FtpsOnly"
39+
managed_pipeline_mode = "Integrated"
40+
use_32_bit_worker_process = true
41+
windows_fx_version = "DOTNETCORE|2.1"
42+
}
43+
44+
# (Optional) A key-value pair of Application Settings
45+
app_settings = {
46+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
47+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
48+
DiagnosticServices_EXTENSION_VERSION = "~3"
49+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
50+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
51+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
52+
XDT_MicrosoftApplicationInsights_Java = "1"
53+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
54+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
55+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
56+
}
57+
58+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
59+
# You can configure the backups to be retained up to an indefinite amount of time.
60+
# Azure storage account and container in the same subscription as the app that you want to back up.
61+
# This module creates a Storage Container to keep the all backup items.
62+
# Backup items - App configuration , File content, Database connected to your app
63+
enable_backup = true
64+
storage_account_name = "stdiagfortesting"
65+
backup_settings = {
66+
enabled = true
67+
name = "DefaultBackup"
68+
frequency_interval = 1
69+
frequency_unit = "Day"
70+
retention_period_in_days = 90
71+
}
72+
73+
# By default App Insight resource is created by this module.
74+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
75+
# Specifies the type of Application by setting up `application_insights_type` with valid string
76+
# Specifies the retention period in days using `retention_in_days`. Default 90.
77+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
78+
app_insights_name = "otkpocshared"
79+
80+
# Adding TAG's to your Azure resources
81+
tags = {
82+
ProjectName = "demo-internal"
83+
Env = "dev"
84+
Owner = "user@example.com"
85+
BusinessUnit = "CORP"
86+
ServiceClass = "Gold"
87+
}
88+
}
89+
```
90+
91+
## Terraform Usage
92+
93+
To run this example you need to execute following Terraform commands
94+
95+
```hcl
96+
terraform init
97+
98+
terraform plan
99+
100+
terraform apply
101+
```
102+
103+
Run `terraform destroy` when you don't need these resources.

examples/complete/main.tf

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
module "web-app" {
2+
source = "kumarvna/web-app/azurerm"
3+
version = "1.0.0"
4+
5+
# By default, this module will not create a resource group. Location will be same as existing RG.
6+
# proivde a name to use an existing resource group, specify the existing resource group name,
7+
# set the argument to `create_resource_group = true` to create new resrouce group.
8+
resource_group_name = "rg-shared-westeurope-01"
9+
10+
# App service plan setttings and supported arguments. Default name used by module
11+
# To specify custom name use `app_service_plan_name` with a valid name.
12+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
13+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
14+
service_plan = {
15+
kind = "Windows"
16+
size = "P1v2"
17+
tier = "PremiumV2"
18+
}
19+
20+
# App Service settings and supported arguments
21+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
22+
app_service_name = "mypocproject"
23+
enable_client_affinity = true
24+
25+
# A `site_config` block to setup the application environment.
26+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
27+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
28+
site_config = {
29+
always_on = true
30+
dotnet_framework_version = "v2.0"
31+
ftps_state = "FtpsOnly"
32+
managed_pipeline_mode = "Integrated"
33+
use_32_bit_worker_process = true
34+
windows_fx_version = "DOTNETCORE|2.1"
35+
}
36+
37+
# (Optional) A key-value pair of Application Settings
38+
app_settings = {
39+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
40+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
41+
DiagnosticServices_EXTENSION_VERSION = "~3"
42+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
43+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
44+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
45+
XDT_MicrosoftApplicationInsights_Java = "1"
46+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
47+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
48+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
49+
}
50+
51+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
52+
# You can configure the backups to be retained up to an indefinite amount of time.
53+
# Azure storage account and container in the same subscription as the app that you want to back up.
54+
# This module creates a Storage Container to keep the all backup items.
55+
# Backup items - App configuration , File content, Database connected to your app
56+
enable_backup = true
57+
storage_account_name = "stdiagfortesting"
58+
backup_settings = {
59+
enabled = true
60+
name = "DefaultBackup"
61+
frequency_interval = 1
62+
frequency_unit = "Day"
63+
retention_period_in_days = 90
64+
}
65+
66+
# By default App Insight resource is created by this module.
67+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
68+
# Specifies the type of Application by setting up `application_insights_type` with valid string
69+
# Specifies the retention period in days using `retention_in_days`. Default 90.
70+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
71+
app_insights_name = "otkpocshared"
72+
73+
# Adding TAG's to your Azure resources
74+
tags = {
75+
ProjectName = "demo-internal"
76+
Env = "dev"
77+
Owner = "user@example.com"
78+
BusinessUnit = "CORP"
79+
ServiceClass = "Gold"
80+
}
81+
}

examples/complete/output.tf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
output "app_service_plan_id" {
2+
description = "The resource ID of the App Service Plan component"
3+
value = module.web-app.app_service_plan_id
4+
}
5+
6+
output "maximum_number_of_workers" {
7+
description = " The maximum number of workers supported with the App Service Plan's sku"
8+
value = module.web-app.maximum_number_of_workers
9+
}
10+
11+
output "app_service_id" {
12+
description = "The resource ID of the App Service component"
13+
value = module.web-app.app_service_id
14+
}
15+
16+
output "default_site_hostname" {
17+
description = "The Default Hostname associated with the App Service"
18+
value = module.web-app.default_site_hostname
19+
}
20+
21+
output "outbound_ip_addresses" {
22+
description = "A comma separated list of outbound IP addresses"
23+
value = module.web-app.outbound_ip_addresses
24+
}
25+
26+
output "outbound_ip_address_list" {
27+
description = "A list of outbound IP addresses"
28+
value = module.web-app.outbound_ip_address_list
29+
}
30+
31+
output "possible_outbound_ip_addresses" {
32+
description = "A comma separated list of outbound IP addresses - not all of which are necessarily in use. Superset of `outbound_ip_addresses`."
33+
value = module.web-app.possible_outbound_ip_addresses
34+
}
35+
36+
output "possible_outbound_ip_address_list" {
37+
description = "A list of outbound IP addresses - not all of which are necessarily in use. Superset of outbound_ip_address_list."
38+
value = module.web-app.possible_outbound_ip_address_list
39+
}
40+
41+
output "identity" {
42+
description = "An identity block, which contains the Managed Service Identity information for this App Service."
43+
value = module.web-app.identity
44+
}
45+
46+
output "application_insights_id" {
47+
description = "The ID of the Application Insights component"
48+
value = module.web-app.application_insights_id
49+
}
50+
51+
output "application_insights_app_id" {
52+
description = "The App ID associated with this Application Insights component"
53+
value = module.web-app.application_insights_app_id
54+
}
55+
56+
output "application_insights_instrumentation_key" {
57+
description = "The Instrumentation Key for this Application Insights component"
58+
value = module.web-app.application_insights_instrumentation_key
59+
sensitive = true
60+
}
61+
62+
output "application_insights_connection_string" {
63+
description = "The Connection String for this Application Insights component"
64+
value = module.web-app.application_insights_connection_string
65+
sensitive = true
66+
}
67+
68+
output "sas_url_query_string" {
69+
value = module.web-app.sas_url_query_string
70+
sensitive = true
71+
}
72+

graph.png

537 KB
Loading

0 commit comments

Comments
 (0)