Skip to content

Commit b54386f

Browse files
authored
Merge c95e5f9 into 659d61c
2 parents 659d61c + c95e5f9 commit b54386f

File tree

6 files changed

+202
-0
lines changed

6 files changed

+202
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Terraform Template - Azure Traffic Manager
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 Traffic Manager profile, including DNS configuration and endpoint monitoring.
13+
14+
> [!NOTE]
15+
> This Traffic Manager configuration uses best practices for routing, monitoring, and DNS setup.
16+
17+
<p align="center">
18+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/32680750-b3c9-4149-b0a9-677bcaccffca">
19+
</p>
20+
21+
## File Descriptions
22+
23+
- **main.tf**: Contains the main configuration for creating the Azure Traffic Manager profile 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 Traffic Manager profile ID and FQDN.
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+
| `resource_group_name` | The name of the resource group | string | `"tm-resource-group"` |
36+
| `location` | The Azure region for the resource group | string | `"eastus"` |
37+
| `traffic_manager_name` | The name of the Traffic Manager profile | string | `"my-tm-profile"` |
38+
| `traffic_routing_method`| The traffic routing method (Performance, Priority, etc.) | string | `"Performance"` |
39+
| `dns_name` | The relative DNS name for the Traffic Manager profile | string | `"mytmprofile"` |
40+
| `ttl` | The DNS Time-To-Live (TTL) in seconds | number | `30` |
41+
| `monitor_protocol` | The protocol used for endpoint monitoring | string | `"HTTP"` |
42+
| `monitor_port` | The port used for endpoint monitoring | number | `80` |
43+
| `monitor_path` | The path used for endpoint monitoring | string | `"/"` |
44+
45+
## Usage
46+
47+
1. Clone the repository and navigate to the traffic-manager 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+
| `traffic_manager_profile_id` | The ID of the Traffic Manager profile |
62+
| `traffic_manager_fqdn` | The FQDN of the Traffic Manager profile |
63+
64+
<div align="center">
65+
<h3 style="color: #4CAF50;">Total Visitors</h3>
66+
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
67+
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# main.tf
2+
# This file contains the main configuration for creating an Azure Traffic Manager profile.
3+
4+
# Resource Group
5+
resource "azurerm_resource_group" "tm" {
6+
name = var.resource_group_name
7+
location = var.location
8+
}
9+
10+
# Traffic Manager Profile
11+
resource "azurerm_traffic_manager_profile" "tm" {
12+
name = var.traffic_manager_name
13+
resource_group_name = azurerm_resource_group.tm.name
14+
traffic_routing_method = var.traffic_routing_method
15+
16+
dns_config {
17+
relative_name = var.dns_name
18+
ttl = var.ttl
19+
}
20+
21+
monitor_config {
22+
protocol = var.monitor_protocol
23+
port = var.monitor_port
24+
path = var.monitor_path
25+
}
26+
27+
# Add endpoints as needed using azurerm_traffic_manager_endpoint resources
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# outputs.tf
2+
# This file defines the outputs for the Traffic Manager configuration.
3+
4+
output "traffic_manager_profile_id" {
5+
description = "The ID of the Traffic Manager profile"
6+
value = azurerm_traffic_manager_profile.tm.id
7+
}
8+
9+
output "traffic_manager_fqdn" {
10+
description = "The FQDN of the Traffic Manager profile"
11+
value = azurerm_traffic_manager_profile.tm.fqdn
12+
}
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 = "407f4106-0fd3-42e0-9348-3686dd1e7347" # your-subscription-id
7+
8+
# Resource Group
9+
resource_group_name = "RG-trafficmanager-test" # your-resource-group-name
10+
location = "eastus"
11+
12+
# Traffic Manager Configuration
13+
traffic_manager_name = "my-tm-profile"
14+
traffic_routing_method = "Performance"
15+
dns_name = "mytmprofilebrowntest"
16+
ttl = 30
17+
monitor_protocol = "HTTP"
18+
monitor_port = 80
19+
monitor_path = "/"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# variables.tf
2+
# This file defines the input variables used in the Terraform configuration.
3+
4+
variable "subscription_id" {
5+
description = "The Azure subscription ID"
6+
type = string
7+
}
8+
9+
variable "resource_group_name" {
10+
description = "The name of the resource group"
11+
type = string
12+
}
13+
14+
variable "location" {
15+
description = "The Azure region for the resource group"
16+
type = string
17+
}
18+
19+
variable "traffic_manager_name" {
20+
description = "The name of the Traffic Manager profile"
21+
type = string
22+
}
23+
24+
variable "traffic_routing_method" {
25+
description = "The traffic routing method (e.g., Performance, Priority, Weighted, Geographic, MultiValue, Subnet)"
26+
type = string
27+
default = "Performance"
28+
}
29+
30+
variable "dns_name" {
31+
description = "The relative DNS name for the Traffic Manager profile"
32+
type = string
33+
}
34+
35+
variable "ttl" {
36+
description = "The DNS Time-To-Live (TTL) in seconds"
37+
type = number
38+
default = 30
39+
}
40+
41+
variable "monitor_protocol" {
42+
description = "The protocol used for endpoint monitoring (HTTP, HTTPS, TCP)"
43+
type = string
44+
default = "HTTP"
45+
}
46+
47+
variable "monitor_port" {
48+
description = "The port used for endpoint monitoring"
49+
type = number
50+
default = 80
51+
}
52+
53+
variable "monitor_path" {
54+
description = "The path used for endpoint monitoring"
55+
type = string
56+
default = "/"
57+
}

0 commit comments

Comments
 (0)