Skip to content

Commit

Permalink
Merge pull request #1 from PashmakGuru/refactor/terraform-fmt
Browse files Browse the repository at this point in the history
🔨 Reformat Terraform Files
  • Loading branch information
AmirrezaNasiri authored Dec 30, 2023
2 parents 7e67382 + a167718 commit a77d0a9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion 05-domains.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resource "azurerm_resource_group" "this" {
}

resource "azurerm_dns_zone" "this" {
for_each = toset(var.zones)
for_each = toset(var.zones)
name = each.value
resource_group_name = azurerm_resource_group.this.name
}
28 changes: 14 additions & 14 deletions 06-front-door.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ resource "azurerm_cdn_frontdoor_profile" "this" {
# }

resource "azurerm_cdn_frontdoor_origin_group" "this" {
for_each = toset(var.origin_groups)
name = each.key
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.this.id
session_affinity_enabled = true
for_each = toset(var.origin_groups)
name = each.key
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.this.id
session_affinity_enabled = true
restore_traffic_time_to_healed_or_new_endpoint_in_minutes = 1

load_balancing {
Expand All @@ -31,13 +31,13 @@ resource "azurerm_cdn_frontdoor_origin_group" "this" {
}

data "azurerm_public_ips" "this" {
for_each = var.public_ip_origins
for_each = var.public_ip_origins
resource_group_name = each.value.pip_resource_group_name
name_prefix = each.value.pip_name_prefix
name_prefix = each.value.pip_name_prefix
}

resource "azurerm_cdn_frontdoor_origin" "this" {
for_each = var.public_ip_origins
for_each = var.public_ip_origins
name = each.key
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.this[each.value.origin_group_name].id
enabled = true
Expand All @@ -51,35 +51,35 @@ resource "azurerm_cdn_frontdoor_origin" "this" {
}

resource "azurerm_cdn_frontdoor_endpoint" "this" {
for_each = toset(var.endpoints)
for_each = toset(var.endpoints)
name = each.key
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.this.id
}

resource "azurerm_cdn_frontdoor_rule_set" "this" {
for_each = toset(var.rule_sets)
for_each = toset(var.rule_sets)
name = each.key
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.this.id
}

resource "azurerm_cdn_frontdoor_route" "this" {
for_each = var.routes
for_each = var.routes
name = each.key
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.this[each.value.endpoint_name].id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.this[each.value.origin_group_name].id
cdn_frontdoor_origin_ids = [
cdn_frontdoor_origin_ids = [
for name in each.value.origin_names : azurerm_cdn_frontdoor_origin.this[name].id
]
cdn_frontdoor_rule_set_ids = [
cdn_frontdoor_rule_set_ids = [
for name in each.value.rule_set_names : azurerm_cdn_frontdoor_rule_set.this[name].id
]
enabled = true
enabled = true

forwarding_protocol = "HttpOnly"
patterns_to_match = each.value.patterns_to_match
supported_protocols = ["Http", "Https"]
https_redirect_enabled = true

#cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id, azurerm_cdn_frontdoor_custom_domain.fabrikam.id]
link_to_default_domain = each.value.use_azure_domain
link_to_default_domain = each.value.use_azure_domain
}
14 changes: 7 additions & 7 deletions example/instance.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ locals {
}

module "front_hub" {
source = "./../"
source = "./../"

resource_group_name = "front-hub-solution_example-testing"
resource_group_name = "front-hub-solution_example-testing"
resource_group_location = "West US"

zones = local.data.zones
origin_groups = local.data.origin_groups
zones = local.data.zones
origin_groups = local.data.origin_groups
public_ip_origins = local.data.public_ip_origins
endpoints = local.data.endpoints
rule_sets = local.data.rule_sets
routes = local.data.routes
endpoints = local.data.endpoints
rule_sets = local.data.rule_sets
routes = local.data.routes
}

output "name_servers" {
Expand Down
8 changes: 4 additions & 4 deletions example/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_providers {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.79.0"
Expand All @@ -21,7 +21,7 @@ provider "azurerm" {

# Connection to Azure
subscription_id = var.azure_subscription_id
client_id = var.azure_client_id
client_secret = var.azure_client_secret
tenant_id = var.azure_tenant_id
client_id = var.azure_client_id
client_secret = var.azure_client_secret
tenant_id = var.azure_tenant_id
}
12 changes: 6 additions & 6 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ output "name_servers" {
}

output "urls" {
value = {
for endpointName, endpoint in azurerm_cdn_frontdoor_endpoint.this:
endpointName => {
# TODO: Add a unique identifier
host_name: endpoint.host_name
}
value = {
for endpointName, endpoint in azurerm_cdn_frontdoor_endpoint.this :
endpointName => {
# TODO: Add a unique identifier
host_name : endpoint.host_name
}
}
}
26 changes: 13 additions & 13 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ variable "resource_group_name" {
}

variable "resource_group_location" {
type = string
type = string
default = "West US"
}

# [
# "pashmak.guru"
# ]
variable "zones" {
type = list(string)
type = list(string)
}

# [
Expand All @@ -30,19 +30,19 @@ variable "origin_groups" {
# }
# }
variable "public_ip_origins" {
type = map(object({
origin_group_name = string
pip_resource_group_name = string
pip_name_prefix = string
origin_host_header = string
}))
type = map(object({
origin_group_name = string
pip_resource_group_name = string
pip_name_prefix = string
origin_host_header = string
}))
}

# [
# "argocd-admin-pashmak-guru"
# ]
variable "endpoints" {
type = list(string)
type = list(string)
}

# [
Expand All @@ -69,11 +69,11 @@ variable "rule_sets" {
# }
variable "routes" {
type = map(object({
endpoint_name = string
endpoint_name = string
origin_group_name = string
origin_names = list(string)
rule_set_names = list(string)
origin_names = list(string)
rule_set_names = list(string)
patterns_to_match = list(string)
use_azure_domain = bool
use_azure_domain = bool
}))
}

0 comments on commit a77d0a9

Please sign in to comment.