diff --git a/3_networking/traffic-manager/README.md b/3_networking/traffic-manager/README.md new file mode 100644 index 0000000..a707dad --- /dev/null +++ b/3_networking/traffic-manager/README.md @@ -0,0 +1,67 @@ +# Terraform Template - Azure Traffic Manager + +Costa Rica + +[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) +[brown9804](https://github.com/brown9804) + +Last updated: 2025-06-12 + +---------- + +> This template contains Terraform configurations to create and manage an Azure Traffic Manager profile, including DNS configuration and endpoint monitoring. + +> [!NOTE] +> This Traffic Manager configuration uses best practices for routing, monitoring, and DNS setup. + +

+ image +

+ +## File Descriptions + +- **main.tf**: Contains the main configuration for creating the Azure Traffic Manager profile and its associated resources. +- **variables.tf**: Defines the input variables used in the Terraform configuration. +- **provider.tf**: Configures the Azure provider to interact with Azure resources. +- **terraform.tfvars**: Provides default values for the variables defined in `variables.tf`. +- **outputs.tf**: Defines the outputs such as Traffic Manager profile ID and FQDN. + +## Variables + +Below is a list of variables used in this template, their expected values, types, and examples: + +| Variable Name | Description | Type | Example Value | +|------------------------ |-------------------------------------------------------|--------------|----------------------| +| `resource_group_name` | The name of the resource group | string | `"tm-resource-group"` | +| `location` | The Azure region for the resource group | string | `"eastus"` | +| `traffic_manager_name` | The name of the Traffic Manager profile | string | `"my-tm-profile"` | +| `traffic_routing_method`| The traffic routing method (Performance, Priority, etc.) | string | `"Performance"` | +| `dns_name` | The relative DNS name for the Traffic Manager profile | string | `"mytmprofile"` | +| `ttl` | The DNS Time-To-Live (TTL) in seconds | number | `30` | +| `monitor_protocol` | The protocol used for endpoint monitoring | string | `"HTTP"` | +| `monitor_port` | The port used for endpoint monitoring | number | `80` | +| `monitor_path` | The path used for endpoint monitoring | string | `"/"` | + +## Usage + +1. Clone the repository and navigate to the traffic-manager directory. +2. Update the `terraform.tfvars` file with your values. +3. Initialize and apply the Terraform configuration: + +```bash +terraform init +terraform plan +terraform apply +``` + +## Outputs + +| Output Name | Description | +|----------------------------|---------------------------------------------| +| `traffic_manager_profile_id` | The ID of the Traffic Manager profile | +| `traffic_manager_fqdn` | The FQDN of the Traffic Manager profile | + +
+

Total Visitors

+ Visitor Count +
diff --git a/3_networking/traffic-manager/main.tf b/3_networking/traffic-manager/main.tf new file mode 100644 index 0000000..9351aea --- /dev/null +++ b/3_networking/traffic-manager/main.tf @@ -0,0 +1,28 @@ +# main.tf +# This file contains the main configuration for creating an Azure Traffic Manager profile. + +# Resource Group +resource "azurerm_resource_group" "tm" { + name = var.resource_group_name + location = var.location +} + +# Traffic Manager Profile +resource "azurerm_traffic_manager_profile" "tm" { + name = var.traffic_manager_name + resource_group_name = azurerm_resource_group.tm.name + traffic_routing_method = var.traffic_routing_method + + dns_config { + relative_name = var.dns_name + ttl = var.ttl + } + + monitor_config { + protocol = var.monitor_protocol + port = var.monitor_port + path = var.monitor_path + } + + # Add endpoints as needed using azurerm_traffic_manager_endpoint resources +} \ No newline at end of file diff --git a/3_networking/traffic-manager/outputs.tf b/3_networking/traffic-manager/outputs.tf new file mode 100644 index 0000000..39e2c72 --- /dev/null +++ b/3_networking/traffic-manager/outputs.tf @@ -0,0 +1,12 @@ +# outputs.tf +# This file defines the outputs for the Traffic Manager configuration. + +output "traffic_manager_profile_id" { + description = "The ID of the Traffic Manager profile" + value = azurerm_traffic_manager_profile.tm.id +} + +output "traffic_manager_fqdn" { + description = "The FQDN of the Traffic Manager profile" + value = azurerm_traffic_manager_profile.tm.fqdn +} \ No newline at end of file diff --git a/3_networking/traffic-manager/provider.tf b/3_networking/traffic-manager/provider.tf new file mode 100644 index 0000000..f3f9b2d --- /dev/null +++ b/3_networking/traffic-manager/provider.tf @@ -0,0 +1,19 @@ +# provider.tf +# This file configures the Azure provider to interact with Azure resources. +# It specifies the required provider and its version, along with provider-specific configurations. + +terraform { + required_version = ">= 1.8, < 2.0" + # Specify the required provider and its version + required_providers { + azurerm = { + source = "hashicorp/azurerm" # Source of the AzureRM provider + version = "~> 4.16.0" # Version of the AzureRM provider + } + } +} + +provider "azurerm" { + features {} # Enable all features for the AzureRM provider + subscription_id = var.subscription_id # Use the subscription ID variable +} diff --git a/3_networking/traffic-manager/terraform.tfvars b/3_networking/traffic-manager/terraform.tfvars new file mode 100644 index 0000000..ea982be --- /dev/null +++ b/3_networking/traffic-manager/terraform.tfvars @@ -0,0 +1,19 @@ +# terraform.tfvars +# This file provides default values for the variables defined in variables.tf. +# These values can be overridden by specifying different values during Terraform execution. + +# Azure Subscription +subscription_id = "" # your-subscription-id + +# Resource Group +resource_group_name = "RG-trafficmanager-test" # your-resource-group-name +location = "eastus" + +# Traffic Manager Configuration +traffic_manager_name = "my-tm-profile" +traffic_routing_method = "Performance" +dns_name = "mytmprofilebrowntest" +ttl = 30 +monitor_protocol = "HTTP" +monitor_port = 80 +monitor_path = "/" diff --git a/3_networking/traffic-manager/variables.tf b/3_networking/traffic-manager/variables.tf new file mode 100644 index 0000000..b659d8c --- /dev/null +++ b/3_networking/traffic-manager/variables.tf @@ -0,0 +1,57 @@ +# variables.tf +# This file defines the input variables used in the Terraform configuration. + +variable "subscription_id" { + description = "The Azure subscription ID" + type = string +} + +variable "resource_group_name" { + description = "The name of the resource group" + type = string +} + +variable "location" { + description = "The Azure region for the resource group" + type = string +} + +variable "traffic_manager_name" { + description = "The name of the Traffic Manager profile" + type = string +} + +variable "traffic_routing_method" { + description = "The traffic routing method (e.g., Performance, Priority, Weighted, Geographic, MultiValue, Subnet)" + type = string + default = "Performance" +} + +variable "dns_name" { + description = "The relative DNS name for the Traffic Manager profile" + type = string +} + +variable "ttl" { + description = "The DNS Time-To-Live (TTL) in seconds" + type = number + default = 30 +} + +variable "monitor_protocol" { + description = "The protocol used for endpoint monitoring (HTTP, HTTPS, TCP)" + type = string + default = "HTTP" +} + +variable "monitor_port" { + description = "The port used for endpoint monitoring" + type = number + default = 80 +} + +variable "monitor_path" { + description = "The path used for endpoint monitoring" + type = string + default = "/" +}