Skip to content

Commit 7219a0a

Browse files
authored
Merge caf72bd into e878053
2 parents e878053 + caf72bd commit 7219a0a

File tree

6 files changed

+259
-0
lines changed

6 files changed

+259
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Terraform Template - Azure Application Gateway
2+
3+
Costa Rica
4+
5+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
6+
[brown9804](https://github.com/brown9804)
7+
8+
Last updated: 2025-06-12
9+
10+
----------
11+
12+
> This template contains Terraform configurations to create and manage an Azure Application Gateway with its associated components including public IP, backend pool, and request routing rules.
13+
14+
> [!NOTE]
15+
> The Application Gateway configuration uses Standard_v2 SKU, providing enhanced features like autoscaling, zone redundancy, and Web Application Firewall.
16+
17+
<p align="center">
18+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/d2f8a37d-f1bc-4da5-9fff-eb8e89905315">
19+
</p>
20+
21+
## File Descriptions
22+
23+
- **main.tf**: Contains the main configuration for creating the Azure Application Gateway and its associated resources.
24+
- **variables.tf**: Defines the input variables used in the Terraform configuration.
25+
- **provider.tf**: Configures the Azure provider to interact with Azure resources.
26+
- **terraform.tfvars**: Provides default values for the variables defined in `variables.tf`.
27+
- **outputs.tf**: Defines the outputs such as Application Gateway ID and public IP address.
28+
29+
## Variables
30+
31+
> Below is a list of variables used in this template, their expected values, types, and examples:
32+
33+
| Variable Name | Description | Type | Example Value |
34+
|--------------|-------------|------|---------------|
35+
| `subscription_id` | The Azure subscription ID | string | `"12345678-abcd-efgh-ijkl-9876543210"` |
36+
| `resource_group_name` | The name of the resource group | string | `"appgw-resource-group"` |
37+
| `location` | The Azure region to deploy resources | string | `"eastus"` |
38+
| `public_ip_name` | The name of the public IP address | string | `"appgw-public-ip"` |
39+
| `app_gateway_name` | The name of the Application Gateway | string | `"my-app-gateway"` |
40+
| `vnet_name` | The name of the virtual network | string | `"appgw-vnet"` |
41+
| `vnet_address_space` | The address space of the virtual network | list(string) | `["10.0.0.0/16"]` |
42+
| `subnet_name` | The name of the subnet for the Application Gateway | string | `"appgw-subnet"` |
43+
| `subnet_address_prefixes` | The address prefixes for the subnet | list(string) | `["10.0.1.0/24"]` |
44+
45+
## Usage
46+
47+
1. Clone the repository and navigate to the application gateway directory.
48+
2. Update the `terraform.tfvars` file with your values.
49+
3. Initialize and apply the Terraform configuration:
50+
51+
```bash
52+
terraform init
53+
terraform plan
54+
terraform apply
55+
```
56+
57+
## Outputs
58+
59+
| Output Name | Description |
60+
|-------------|-------------|
61+
| `application_gateway_id` | The ID of the Application Gateway |
62+
| `public_ip_address` | The frontend public IP address of the Application Gateway |
63+
| `virtual_network_name` | The name of the virtual network |
64+
| `subnet_name` | The name of the subnet used by the Application Gateway |
65+
66+
<div align="center">
67+
<h3 style="color: #4CAF50;">Total Visitors</h3>
68+
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
69+
</div>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Azure Application Gateway minimal configuration
2+
3+
resource "azurerm_resource_group" "agw" {
4+
name = var.resource_group_name
5+
location = var.location
6+
}
7+
8+
resource "azurerm_virtual_network" "vnet" {
9+
name = var.vnet_name
10+
location = azurerm_resource_group.agw.location
11+
resource_group_name = azurerm_resource_group.agw.name
12+
address_space = var.vnet_address_space
13+
}
14+
15+
resource "azurerm_subnet" "subnet" {
16+
name = var.subnet_name
17+
resource_group_name = azurerm_resource_group.agw.name
18+
virtual_network_name = azurerm_virtual_network.vnet.name
19+
address_prefixes = var.subnet_address_prefixes
20+
}
21+
22+
resource "azurerm_public_ip" "agw" {
23+
name = var.public_ip_name
24+
location = azurerm_resource_group.agw.location
25+
resource_group_name = azurerm_resource_group.agw.name
26+
allocation_method = "Static"
27+
sku = "Standard"
28+
}
29+
30+
resource "azurerm_application_gateway" "agw" {
31+
name = var.app_gateway_name
32+
location = azurerm_resource_group.agw.location
33+
resource_group_name = azurerm_resource_group.agw.name
34+
sku {
35+
name = "Standard_v2"
36+
tier = "Standard_v2"
37+
capacity = 2
38+
}
39+
gateway_ip_configuration {
40+
name = "appGatewayIpConfig"
41+
subnet_id = azurerm_subnet.subnet.id
42+
}
43+
frontend_port {
44+
name = "frontendPort"
45+
port = 80
46+
}
47+
frontend_ip_configuration {
48+
name = "frontendIpConfig"
49+
public_ip_address_id = azurerm_public_ip.agw.id
50+
}
51+
backend_address_pool {
52+
name = "backendPool"
53+
}
54+
backend_http_settings {
55+
name = "httpSettings"
56+
cookie_based_affinity = "Disabled"
57+
port = 80
58+
protocol = "Http"
59+
}
60+
http_listener {
61+
name = "httpListener"
62+
frontend_ip_configuration_name = "frontendIpConfig"
63+
frontend_port_name = "frontendPort"
64+
protocol = "Http"
65+
}
66+
67+
request_routing_rule {
68+
name = "rule1"
69+
rule_type = "Basic"
70+
http_listener_name = "httpListener"
71+
backend_address_pool_name = "backendPool"
72+
backend_http_settings_name = "httpSettings"
73+
priority = 320 # Add a priority value (1-20000)
74+
}
75+
76+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# outputs.tf
2+
# This file defines the outputs of the Terraform configuration.
3+
4+
output "resource_group_name" {
5+
description = "The name of the resource group"
6+
value = azurerm_resource_group.agw.name
7+
}
8+
9+
output "application_gateway_id" {
10+
description = "The ID of the Application Gateway"
11+
value = azurerm_application_gateway.agw.id
12+
}
13+
14+
output "application_gateway_frontend_ip" {
15+
description = "The frontend public IP address of the Application Gateway"
16+
value = azurerm_public_ip.agw.ip_address
17+
}
18+
19+
output "virtual_network_name" {
20+
description = "The name of the virtual network"
21+
value = azurerm_virtual_network.vnet.name
22+
}
23+
24+
output "subnet_name" {
25+
description = "The name of the subnet used by the Application Gateway"
26+
value = azurerm_subnet.subnet.name
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# provider.tf
2+
# This file configures the Azure provider to interact with Azure resources.
3+
# It specifies the required provider and its version, along with provider-specific configurations.
4+
5+
terraform {
6+
required_version = ">= 1.8, < 2.0"
7+
# Specify the required provider and its version
8+
required_providers {
9+
azurerm = {
10+
source = "hashicorp/azurerm" # Source of the AzureRM provider
11+
version = "~> 4.16.0" # Version of the AzureRM provider
12+
}
13+
}
14+
}
15+
16+
provider "azurerm" {
17+
features {} # Enable all features for the AzureRM provider
18+
subscription_id = var.subscription_id # Use the subscription ID variable
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# terraform.tfvars
2+
# This file provides default values for the variables defined in variables.tf.
3+
# These values can be overridden by specifying different values during Terraform execution.
4+
5+
# Azure Subscription
6+
subscription_id = "" # your-subscription-id
7+
8+
# Resource Group
9+
resource_group_name = "RG-appgateway-test" # your-resource-group-name
10+
location = "eastus"
11+
12+
# Application Gateway Configuration
13+
public_ip_name = "demo-public-ip"
14+
app_gateway_name = "demo-app-gateway"
15+
16+
vnet_name = "demo-vnet"
17+
vnet_address_space = ["10.0.0.0/16"] # your-vnet-address-space
18+
19+
subnet_name = "demo-subnet"
20+
subnet_address_prefixes = ["10.0.1.0/24"] # your-subnet-address-prefix
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# variables.tf
2+
# This file defines the input variables used in the Terraform configuration.
3+
# Each variable includes a description and type.
4+
5+
variable "subscription_id" {
6+
description = "The Azure subscription ID"
7+
type = string
8+
}
9+
10+
variable "resource_group_name" {
11+
description = "The name of the resource group"
12+
type = string
13+
}
14+
15+
variable "location" {
16+
description = "The Azure region to deploy resources"
17+
type = string
18+
}
19+
20+
variable "public_ip_name" {
21+
description = "The name of the public IP address"
22+
type = string
23+
}
24+
25+
variable "app_gateway_name" {
26+
description = "The name of the Application Gateway"
27+
type = string
28+
}
29+
30+
variable "vnet_name" {
31+
description = "The name of the virtual network"
32+
type = string
33+
}
34+
35+
variable "vnet_address_space" {
36+
description = "The address space of the virtual network"
37+
type = list(string)
38+
}
39+
40+
variable "subnet_name" {
41+
description = "The name of the subnet for the Application Gateway"
42+
type = string
43+
}
44+
45+
variable "subnet_address_prefixes" {
46+
description = "The address prefixes for the subnet"
47+
type = list(string)
48+
}

0 commit comments

Comments
 (0)