Skip to content

Commit eebd597

Browse files
authored
Merge pull request #6 from kumarvna/develop
adding vnet integration feature
2 parents 16abe5e + b59e47e commit eebd597

File tree

12 files changed

+629
-9
lines changed

12 files changed

+629
-9
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ provider "azurerm" {
1515
1616
module "app-service" {
1717
source = "kumarvna/app-service/azurerm"
18-
version = "1.0.0"
18+
version = "1.1.0"
1919
2020
# By default, this module will not create a resource group. Location will be same as existing RG.
2121
# proivde a name to use an existing resource group, specify the existing resource group name,
@@ -307,6 +307,14 @@ Your application can be granted two types of identities:
307307
type| Specifies the identity type of the App Service. Possible values are `SystemAssigned` (where Azure will generate a Service Principal for you), `UserAssigned` where you can specify the Service Principal IDs in the `identity_ids` field, and `SystemAssigned, UserAssigned` which assigns both a system managed identity as well as the specified user assigned identities. When `type` is set to `SystemAssigned`, The assigned `principal_id` and `tenant_id` can be retrieved after the App Service has been created.
308308
identity_ids|Specifies a list of user managed identity ids to be assigned. Required if `type` is `UserAssigned`.
309309

310+
## VNet Integration - Integrate app with an Azure virtual network
311+
312+
VNet integration gives your app access to resources in your VNet, but it doesn't grant inbound private access to your app from the VNet. Private site access refers to making an app accessible only from a private network, such as from within an Azure virtual network. VNet integration is used only to make outbound calls from your app into your VNet. This feature requires a `Standard`, `Premium`, `PremiumV2`, `PremiumV3`, or `Elastic Premium` App Service pricing tier.
313+
314+
This feature can be enabled by setting up `enable_vnet_integration` varaible to `true` and providing a valid `subnet_id`. The subnet must have a `service_delegation` configured for `Microsoft.Web/serverFarms`
315+
316+
[Example usage of App service with VNet Integration](examples/app-service-with-vnet-integration/)
317+
310318
## App Insights
311319

312320
Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals. Use it to monitor your live applications. It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability. It works for apps on a wide variety of platforms including .NET, Node.js, Java, and Python hosted on-premises, hybrid, or any public cloud. It integrates with your DevOps process, and has connection points to a variety of development tools. It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center.
@@ -352,6 +360,7 @@ An effective naming convention assembles resource names by using important resou
352360
`create_resource_group` | Whether to create resource group and use it for all networking resources | string | `"false"`
353361
`resource_group_name` | The name of the resource group in which resources are created | string | `""`
354362
`location` | The location of the resource group in which resources are created | string | `""`
363+
`subnet_id`|The resource id of the subnet for regional vnet integration|string|`""`
355364
`app_service_plan_name` | Specifies the name of the App Service Plan component | string | `""`
356365
`service_plan` | Definition of the dedicated plan to use | object({}) | `{}`
357366
`app_service_name` | Specifies the name of the App Service | string | `""`
@@ -383,6 +392,7 @@ An effective naming convention assembles resource names by using important resou
383392
`application_insights_type` | Specifies the type of Application Insights to create. Valid values are `ios` for iOS, `java` for Java web, `MobileCenter` for App Center, `Node.JS` for Node.js, `other` for General, `phone` for Windows Phone, `store` for Windows Store and `web` for ASP.NET | string | `"web"`
384393
`retention_in_days` | Specifies the retention period in days. Possible values are `30`, `60`, `90`, `120`, `180`, `270`, `365`, `550` or `730` | number | `90`
385394
`disable_ip_masking` | By default the real client ip is masked as `0.0.0.0` in the logs. Use this argument to disable masking and log the real client ip | string | `false`
395+
`enable_vnet_integration`|Manages an App Service Virtual Network Association|string|`false`
386396
`Tags` | A map of tags to add to all resources | map | `{}`
387397

388398
## Outputs
@@ -402,6 +412,7 @@ An effective naming convention assembles resource names by using important resou
402412
`application_insights_app_id` | The App ID associated with this Application Insights component
403413
`application_insights_instrumentation_key` | The Instrumentation Key for this Application Insights component
404414
`application_insights_connection_string` | The Connection String for this Application Insights component
415+
`app_service_virtual_network_swift_connection_id`|The ID of the App Service Virtual Network integration
405416

406417
## Resource Graph
407418

examples/README.md

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
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 to create simple app service with optional resoruces
6+
7+
```hcl
8+
# Azurerm Provider configuration
9+
provider "azurerm" {
10+
features {}
11+
}
12+
13+
module "app-service" {
14+
source = "kumarvna/app-service/azurerm"
15+
version = "1.1.0"
16+
17+
# By default, this module will not create a resource group. Location will be same as existing RG.
18+
# proivde a name to use an existing resource group, specify the existing resource group name,
19+
# set the argument to `create_resource_group = true` to create new resrouce group.
20+
resource_group_name = "rg-shared-westeurope-01"
21+
22+
# App service plan setttings and supported arguments. Default name used by module
23+
# To specify custom name use `app_service_plan_name` with a valid name.
24+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
25+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
26+
service_plan = {
27+
kind = "Windows"
28+
size = "P1v2"
29+
tier = "PremiumV2"
30+
}
31+
32+
# App Service settings and supported arguments
33+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
34+
app_service_name = "myapp-poc-project"
35+
enable_client_affinity = true
36+
37+
# A `site_config` block to setup the application environment.
38+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
39+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
40+
site_config = {
41+
always_on = true
42+
dotnet_framework_version = "v2.0"
43+
ftps_state = "FtpsOnly"
44+
managed_pipeline_mode = "Integrated"
45+
use_32_bit_worker_process = true
46+
windows_fx_version = "DOTNETCORE|2.1"
47+
}
48+
49+
# (Optional) A key-value pair of Application Settings
50+
app_settings = {
51+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
52+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
53+
DiagnosticServices_EXTENSION_VERSION = "~3"
54+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
55+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
56+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
57+
XDT_MicrosoftApplicationInsights_Java = "1"
58+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
59+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
60+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
61+
}
62+
63+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
64+
# You can configure the backups to be retained up to an indefinite amount of time.
65+
# Azure storage account and container in the same subscription as the app that you want to back up.
66+
# This module creates a Storage Container to keep the all backup items.
67+
# Backup items - App configuration , File content, Database connected to your app
68+
enable_backup = true
69+
storage_account_name = "stdiagfortesting1"
70+
backup_settings = {
71+
enabled = true
72+
name = "DefaultBackup"
73+
frequency_interval = 1
74+
frequency_unit = "Day"
75+
retention_period_in_days = 90
76+
}
77+
78+
# By default App Insight resource is created by this module.
79+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
80+
# Specifies the type of Application by setting up `application_insights_type` with valid string
81+
# Specifies the retention period in days using `retention_in_days`. Default 90.
82+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
83+
app_insights_name = "otkpocshared"
84+
85+
# Adding TAG's to your Azure resources
86+
tags = {
87+
ProjectName = "demo-internal"
88+
Env = "dev"
89+
90+
BusinessUnit = "CORP"
91+
ServiceClass = "Gold"
92+
}
93+
}
94+
```
95+
96+
## Module Usage to create app service and optional resoruces with VNet integration
97+
98+
```hcl
99+
# Azurerm Provider configuration
100+
provider "azurerm" {
101+
features {}
102+
}
103+
104+
locals {
105+
tags = {
106+
ProjectName = "demo-internal"
107+
Env = "dev"
108+
109+
BusinessUnit = "CORP"
110+
ServiceClass = "Gold"
111+
}
112+
}
113+
114+
module "vnet" {
115+
source = "kumarvna/vnet/azurerm"
116+
version = "2.1.0"
117+
118+
create_resource_group = false
119+
resource_group_name = "rg-shared-westeurope-01"
120+
vnetwork_name = "vnet-shared-hub-westeurope-002"
121+
location = "westeurope"
122+
vnet_address_space = ["10.2.0.0/16"]
123+
create_network_watcher = false
124+
125+
subnets = {
126+
web_subnet = {
127+
subnet_name = "snet-webapp"
128+
subnet_address_prefix = ["10.2.1.0/24"]
129+
delegation = {
130+
name = "testdelegation"
131+
service_delegation = {
132+
name = "Microsoft.Web/serverFarms"
133+
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
134+
}
135+
}
136+
}
137+
}
138+
tags = local.tags
139+
}
140+
141+
module "app-service" {
142+
source = "kumarvna/app-service/azurerm"
143+
version = "1.1.0"
144+
145+
# By default, this module will not create a resource group. Location will be same as existing RG.
146+
# proivde a name to use an existing resource group, specify the existing resource group name,
147+
# set the argument to `create_resource_group = true` to create new resrouce group.
148+
resource_group_name = "rg-shared-westeurope-01"
149+
150+
# App service plan setttings and supported arguments. Default name used by module
151+
# To specify custom name use `app_service_plan_name` with a valid name.
152+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
153+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
154+
service_plan = {
155+
kind = "Windows"
156+
size = "P1v2"
157+
tier = "PremiumV2"
158+
}
159+
160+
# App Service settings and supported arguments
161+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
162+
app_service_name = "kumarsmypocproject"
163+
enable_client_affinity = true
164+
165+
# A `site_config` block to setup the application environment.
166+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
167+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
168+
site_config = {
169+
always_on = true
170+
dotnet_framework_version = "v2.0"
171+
ftps_state = "FtpsOnly"
172+
managed_pipeline_mode = "Integrated"
173+
use_32_bit_worker_process = true
174+
windows_fx_version = "DOTNETCORE|2.1"
175+
}
176+
177+
# (Optional) A key-value pair of Application Settings
178+
app_settings = {
179+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
180+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
181+
DiagnosticServices_EXTENSION_VERSION = "~3"
182+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
183+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
184+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
185+
XDT_MicrosoftApplicationInsights_Java = "1"
186+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
187+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
188+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
189+
}
190+
191+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
192+
# You can configure the backups to be retained up to an indefinite amount of time.
193+
# Azure storage account and container in the same subscription as the app that you want to back up.
194+
# This module creates a Storage Container to keep the all backup items.
195+
# Backup items - App configuration , File content, Database connected to your app
196+
enable_backup = true
197+
storage_account_name = "stdiagfortesting1"
198+
backup_settings = {
199+
enabled = true
200+
name = "DefaultBackup"
201+
frequency_interval = 1
202+
frequency_unit = "Day"
203+
retention_period_in_days = 90
204+
}
205+
206+
# Regional VNet integration configuration
207+
# Enables you to place the back end of app in a subnet in virtual network in the same region
208+
enable_vnet_integration = true
209+
subnet_id = element(module.vnet.subnet_ids, 0)
210+
211+
# By default App Insight resource is created by this module.
212+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
213+
# Specifies the type of Application by setting up `application_insights_type` with valid string
214+
# Specifies the retention period in days using `retention_in_days`. Default 90.
215+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
216+
app_insights_name = "otkpocshared"
217+
218+
# Adding TAG's to your Azure resources
219+
tags = local.tags
220+
}
221+
```
222+
223+
## Terraform Usage
224+
225+
To run this example you need to execute following Terraform commands
226+
227+
```hcl
228+
terraform init
229+
terraform plan
230+
terraform apply
231+
```
232+
233+
Run `terraform destroy` when you don't need these resources.

0 commit comments

Comments
 (0)