diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b306abb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "terraform" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml new file mode 100644 index 0000000..523ff46 --- /dev/null +++ b/.github/workflows/superlinter.yml @@ -0,0 +1,24 @@ +--- +name: "Code Quality: Super-Linter" +on: + pull_request: +jobs: + superlinter: + name: Super-Linter + runs-on: ubuntu-latest + steps: + + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Lint Code + uses: docker://github/super-linter:v4 + env: + VALIDATE_ALL_CODEBASE: true + DEFAULT_BRANCH: "main" + DISABLE_ERRORS: false + VALIDATE_BASH: true + VALIDATE_JSON: true + VALIDATE_MD: true + VALIDATE_TERRAFORM: true + VALIDATE_YAML: true \ No newline at end of file diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 0000000..2831aff --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,35 @@ +--- +name: "Code Quality: Terraform" +on: + push: + branches: + - main + pull_request: +jobs: + terraform: + name: Terraform + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + +# - name: Terraform Format +# id: fmt +# run: terraform fmt -check -recursive + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + +# - name: Terraform Plan +# id: plan +# run: terraform plan -no-color -input=false +# continue-on-error: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 50e5802..30ccb71 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,12 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* +*tfplan* + +*.terraform.lock.hcl # Mac Files .DS_Store + +# IntelliJ IDEA files +*.idea/ diff --git a/04-Terraform-Language-Syntax/terraform-manifests/top-level-blocks-samples.tf b/04-Terraform-Language-Syntax/terraform-manifests/top-level-blocks-samples.tf index aa61e2f..85d9860 100644 --- a/04-Terraform-Language-Syntax/terraform-manifests/top-level-blocks-samples.tf +++ b/04-Terraform-Language-Syntax/terraform-manifests/top-level-blocks-samples.tf @@ -9,12 +9,12 @@ terraform { } } # Terraform State Storage to Azure Storage Container - backend "azurerm" { +/* backend "azurerm" { resource_group_name = "terraform-storage-rg" storage_account_name = "terraformstate201" container_name = "tfstatefiles" key = "terraform.tfstate" - } + }*/ } ##################################################################### diff --git a/05-Terraform-Provider-Resource-Block-Basics/terraform-manifests/c1-versions.tf b/05-Terraform-Provider-Resource-Block-Basics/terraform-manifests/c1-versions.tf index 18e92aa..866672b 100644 --- a/05-Terraform-Provider-Resource-Block-Basics/terraform-manifests/c1-versions.tf +++ b/05-Terraform-Provider-Resource-Block-Basics/terraform-manifests/c1-versions.tf @@ -1,6 +1,6 @@ # Terraform Block terraform { - required_version = ">= 1.0.0" + required_version = "~> 1.0" required_providers { azurerm = { source = "hashicorp/azurerm" diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c1-versions.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c1-versions.tf index c7519af..5e10510 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c1-versions.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c1-versions.tf @@ -3,11 +3,11 @@ terraform { required_version = ">= 1.0.0" required_providers { azurerm = { - source = "hashicorp/azurerm" - version = ">= 2.0" + source = "hashicorp/azurerm" + version = ">= 2.0" } random = { - source = "hashicorp/random" + source = "hashicorp/random" version = ">= 3.0" } } @@ -15,7 +15,7 @@ terraform { # Provider Block provider "azurerm" { - features {} + features {} } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c2-generic-input-variables.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c2-generic-input-variables.tf index dd40ef9..3b48802 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c2-generic-input-variables.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c2-generic-input-variables.tf @@ -2,27 +2,27 @@ # Business Division variable "business_divsion" { description = "Business Division in the large organization this Infrastructure belongs" - type = string - default = "sap" + type = string + default = "sap" } # Environment Variable variable "environment" { description = "Environment Variable used as a prefix" - type = string - default = "dev" + type = string + default = "dev" } # Azure Resource Group Name variable "resource_group_name" { description = "Resource Group Name" - type = string - default = "rg-default" + type = string + default = "rg-default" } # Azure Resources Location variable "resource_group_location" { description = "Region in which Azure Resources to be created" - type = string - default = "eastus2" + type = string + default = "eastus2" } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c3-locals.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c3-locals.tf index b3da559..150badb 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c3-locals.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c3-locals.tf @@ -1,11 +1,11 @@ # Define Local Values in Terraform locals { - owners = var.business_divsion - environment = var.environment + owners = var.business_divsion + environment = var.environment resource_name_prefix = "${var.business_divsion}-${var.environment}" #name = "${local.owners}-${local.environment}" common_tags = { - owners = local.owners + owners = local.owners environment = local.environment } } \ No newline at end of file diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c4-random-resources.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c4-random-resources.tf index b599262..686c5b7 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c4-random-resources.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c4-random-resources.tf @@ -1,7 +1,7 @@ # Random String Resource resource "random_string" "myrandom" { - length = 6 - upper = false + length = 6 + upper = false special = false - number = false + number = false } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c5-resource-group.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c5-resource-group.tf index c3a7d70..261c58b 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c5-resource-group.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c5-resource-group.tf @@ -1,7 +1,7 @@ # Resource-1: Azure Resource Group resource "azurerm_resource_group" "rg" { # name = "${local.resource_name_prefix}-${var.resource_group_name}" - name = "${local.resource_name_prefix}-${var.resource_group_name}-${random_string.myrandom.id}" + name = "${local.resource_name_prefix}-${var.resource_group_name}-${random_string.myrandom.id}" location = var.resource_group_location - tags = local.common_tags + tags = local.common_tags } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-01-vnet-input-variables.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-01-vnet-input-variables.tf index 3430643..f1a4607 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-01-vnet-input-variables.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-01-vnet-input-variables.tf @@ -3,69 +3,69 @@ ## Virtual Network variable "vnet_name" { description = "Virtual Network name" - type = string - default = "vnet-default" + type = string + default = "vnet-default" } variable "vnet_address_space" { description = "Virtual Network address_space" - type = list(string) - default = ["10.0.0.0/16"] + type = list(string) + default = ["10.0.0.0/16"] } # Web Subnet Name variable "web_subnet_name" { description = "Virtual Network Web Subnet Name" - type = string - default = "websubnet" + type = string + default = "websubnet" } # Web Subnet Address Space variable "web_subnet_address" { description = "Virtual Network Web Subnet Address Spaces" - type = list(string) - default = ["10.0.1.0/24"] + type = list(string) + default = ["10.0.1.0/24"] } # App Subnet Name variable "app_subnet_name" { description = "Virtual Network App Subnet Name" - type = string - default = "appsubnet" + type = string + default = "appsubnet" } # App Subnet Address Space variable "app_subnet_address" { description = "Virtual Network App Subnet Address Spaces" - type = list(string) - default = ["10.0.11.0/24"] + type = list(string) + default = ["10.0.11.0/24"] } # Database Subnet Name variable "db_subnet_name" { description = "Virtual Network Database Subnet Name" - type = string - default = "dbsubnet" + type = string + default = "dbsubnet" } # Database Subnet Address Space variable "db_subnet_address" { description = "Virtual Network Database Subnet Address Spaces" - type = list(string) - default = ["10.0.21.0/24"] + type = list(string) + default = ["10.0.21.0/24"] } # Bastion / Management Subnet Name variable "bastion_subnet_name" { description = "Virtual Network Bastion Subnet Name" - type = string - default = "bastionsubnet" + type = string + default = "bastionsubnet" } # Bastion / Management Subnet Address Space variable "bastion_subnet_address" { description = "Virtual Network Bastion Subnet Address Spaces" - type = list(string) - default = ["10.0.100.0/24"] + type = list(string) + default = ["10.0.100.0/24"] } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-02-virtual-network.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-02-virtual-network.tf index d1eed4e..969e2ab 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-02-virtual-network.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-02-virtual-network.tf @@ -4,5 +4,5 @@ resource "azurerm_virtual_network" "vnet" { address_space = var.vnet_address_space location = azurerm_resource_group.rg.location resource_group_name = azurerm_resource_group.rg.name - tags = local.common_tags + tags = local.common_tags } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-03-web-subnet-and-nsg.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-03-web-subnet-and-nsg.tf index 0a0b7f1..f95c9d0 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-03-web-subnet-and-nsg.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-03-web-subnet-and-nsg.tf @@ -3,7 +3,7 @@ resource "azurerm_subnet" "websubnet" { name = "${azurerm_virtual_network.vnet.name}-${var.web_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name - address_prefixes = var.web_subnet_address + address_prefixes = var.web_subnet_address } # Resource-2: Create Network Security Group (NSG) @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "web_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "web_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.web_nsg_rule_inbound] # Every NSG Rule Association will disassociate NSG from Subnet and Associate it, so we associate it only after NSG is completely created - Azure Provider Bug https://github.com/terraform-providers/terraform-provider-azurerm/issues/354 + depends_on = [azurerm_network_security_rule.web_nsg_rule_inbound] # Every NSG Rule Association will disassociate NSG from Subnet and Associate it, so we associate it only after NSG is completely created - Azure Provider Bug https://github.com/terraform-providers/terraform-provider-azurerm/issues/354 subnet_id = azurerm_subnet.websubnet.id network_security_group_id = azurerm_network_security_group.web_subnet_nsg.id } @@ -27,18 +27,18 @@ locals { "100" : "80", # If the key starts with a number, you must use the colon syntax ":" instead of "=" "110" : "443", "120" : "22" - } + } } ## NSG Inbound Rule for WebTier Subnets resource "azurerm_network_security_rule" "web_nsg_rule_inbound" { - for_each = local.web_inbound_ports_map + for_each = local.web_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-04-app-subnet-and-nsg.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-04-app-subnet-and-nsg.tf index cb560e1..f4bddb1 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-04-app-subnet-and-nsg.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-04-app-subnet-and-nsg.tf @@ -3,7 +3,7 @@ resource "azurerm_subnet" "appsubnet" { name = "${azurerm_virtual_network.vnet.name}-${var.app_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name - address_prefixes = var.app_subnet_address + address_prefixes = var.app_subnet_address } # Resource-2: Create Network Security Group (NSG) @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "app_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "app_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.app_nsg_rule_inbound] + depends_on = [azurerm_network_security_rule.app_nsg_rule_inbound] subnet_id = azurerm_subnet.appsubnet.id network_security_group_id = azurerm_network_security_group.app_subnet_nsg.id } @@ -28,18 +28,18 @@ locals { "110" : "443", "120" : "8080", "130" : "22" - } + } } ## NSG Inbound Rule for AppTier Subnets resource "azurerm_network_security_rule" "app_nsg_rule_inbound" { - for_each = local.app_inbound_ports_map + for_each = local.app_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-05-db-subnet-and-nsg.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-05-db-subnet-and-nsg.tf index 2e60aa8..2b0b05b 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-05-db-subnet-and-nsg.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-05-db-subnet-and-nsg.tf @@ -3,7 +3,7 @@ resource "azurerm_subnet" "dbsubnet" { name = "${azurerm_virtual_network.vnet.name}-${var.db_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name - address_prefixes = var.db_subnet_address + address_prefixes = var.db_subnet_address } # Resource-2: Create Network Security Group (NSG) @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "db_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "db_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.db_nsg_rule_inbound] + depends_on = [azurerm_network_security_rule.db_nsg_rule_inbound] subnet_id = azurerm_subnet.dbsubnet.id network_security_group_id = azurerm_network_security_group.db_subnet_nsg.id } @@ -27,18 +27,18 @@ locals { "100" : "3306", # If the key starts with a number, you must use the colon syntax ":" instead of "=" "110" : "1433", "120" : "5432" - } + } } ## NSG Inbound Rule for DBTier Subnets resource "azurerm_network_security_rule" "db_nsg_rule_inbound" { - for_each = local.db_inbound_ports_map + for_each = local.db_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf index 837e89e..04c59a9 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf @@ -1,6 +1,6 @@ # Resource-1: Create Bastion / Management Subnet resource "azurerm_subnet" "bastionsubnet" { - name = "${azurerm_virtual_network.vnet.name}-${var.bastion_subnet_name}" + name = "${azurerm_virtual_network.vnet.name}-${var.bastion_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name address_prefixes = var.bastion_subnet_address @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "bastion_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "bastion_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.bastion_nsg_rule_inbound] + depends_on = [azurerm_network_security_rule.bastion_nsg_rule_inbound] subnet_id = azurerm_subnet.bastionsubnet.id network_security_group_id = azurerm_network_security_group.bastion_subnet_nsg.id } @@ -26,18 +26,18 @@ locals { bastion_inbound_ports_map = { "100" : "22", # If the key starts with a number, you must use the colon syntax ":" instead of "=" "110" : "3389" - } + } } ## NSG Inbound Rule for Bastion / Management Subnets resource "azurerm_network_security_rule" "bastion_nsg_rule_inbound" { - for_each = local.bastion_inbound_ports_map + for_each = local.bastion_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-07-vnet-outputs.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-07-vnet-outputs.tf index 8c84557..398909e 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-07-vnet-outputs.tf +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/c6-07-vnet-outputs.tf @@ -2,36 +2,36 @@ ## Virtual Network Name output "virtual_network_name" { description = "Virtual Network Name" - value = azurerm_virtual_network.vnet.name + value = azurerm_virtual_network.vnet.name } ## Virtual Network ID output "virtual_network_id" { description = "Virtual Network ID" - value = azurerm_virtual_network.vnet.id + value = azurerm_virtual_network.vnet.id } # Subnet Outputs (We will write for one web subnet and rest all we will ignore for now) ## Subnet Name output "web_subnet_name" { description = "WebTier Subnet Name" - value = azurerm_subnet.websubnet.name + value = azurerm_subnet.websubnet.name } ## Subnet ID output "web_subnet_id" { description = "WebTier Subnet ID" - value = azurerm_subnet.websubnet.id + value = azurerm_subnet.websubnet.id } # Network Security Outputs ## Web Subnet NSG Name output "web_subnet_nsg_name" { description = "WebTier Subnet NSG Name" - value = azurerm_network_security_group.web_subnet_nsg.name + value = azurerm_network_security_group.web_subnet_nsg.name } ## Web Subnet NSG ID output "web_subnet_nsg_id" { description = "WebTier Subnet NSG ID" - value = azurerm_network_security_group.web_subnet_nsg.id + value = azurerm_network_security_group.web_subnet_nsg.id } diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/nwwatcher.tf b/10-Azure-Virtual-Network-4Tier/terraform-manifests/nwwatcher.tf new file mode 100644 index 0000000..1c1327e --- /dev/null +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/nwwatcher.tf @@ -0,0 +1,8 @@ +resource "azurerm_network_watcher" "default" { + location = "eastus" + name = "NetworkWatcher_eastus" + resource_group_name = "NetworkWatcherRG" + tags = {} + + timeouts {} +} \ No newline at end of file diff --git a/10-Azure-Virtual-Network-4Tier/terraform-manifests/terraform.tfvars b/10-Azure-Virtual-Network-4Tier/terraform-manifests/terraform.tfvars index 68d6191..bcf26d9 100644 --- a/10-Azure-Virtual-Network-4Tier/terraform-manifests/terraform.tfvars +++ b/10-Azure-Virtual-Network-4Tier/terraform-manifests/terraform.tfvars @@ -1,18 +1,18 @@ -business_divsion = "hr" -environment = "dev" -resource_group_name = "rg" +business_divsion = "hr" +environment = "dev" +resource_group_name = "rg" resource_group_location = "eastus" -vnet_name = "vnet" -vnet_address_space = ["10.1.0.0/16"] +vnet_name = "vnet" +vnet_address_space = ["10.1.0.0/16"] -web_subnet_name = "websubnet" +web_subnet_name = "websubnet" web_subnet_address = ["10.1.1.0/24"] -app_subnet_name = "appsubnet" +app_subnet_name = "appsubnet" app_subnet_address = ["10.1.11.0/24"] -db_subnet_name = "dbsubnet" +db_subnet_name = "dbsubnet" db_subnet_address = ["10.1.21.0/24"] -bastion_subnet_name = "bastionsubnet" +bastion_subnet_name = "bastionsubnet" bastion_subnet_address = ["10.1.100.0/24"] diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c1-versions.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c1-versions.tf index 2fbbb75..62228ee 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c1-versions.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c1-versions.tf @@ -3,23 +3,23 @@ terraform { required_version = ">= 1.0.0" required_providers { azurerm = { - source = "hashicorp/azurerm" - version = ">= 2.0" + source = "hashicorp/azurerm" + version = ">= 2.0" } random = { - source = "hashicorp/random" + source = "hashicorp/random" version = ">= 3.0" } null = { - source = "hashicorp/null" + source = "hashicorp/null" version = ">= 3.0" - } + } } } # Provider Block provider "azurerm" { - features {} + features {} } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c2-generic-input-variables.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c2-generic-input-variables.tf index dd40ef9..3b48802 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c2-generic-input-variables.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c2-generic-input-variables.tf @@ -2,27 +2,27 @@ # Business Division variable "business_divsion" { description = "Business Division in the large organization this Infrastructure belongs" - type = string - default = "sap" + type = string + default = "sap" } # Environment Variable variable "environment" { description = "Environment Variable used as a prefix" - type = string - default = "dev" + type = string + default = "dev" } # Azure Resource Group Name variable "resource_group_name" { description = "Resource Group Name" - type = string - default = "rg-default" + type = string + default = "rg-default" } # Azure Resources Location variable "resource_group_location" { description = "Region in which Azure Resources to be created" - type = string - default = "eastus2" + type = string + default = "eastus2" } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c3-locals.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c3-locals.tf index b3da559..150badb 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c3-locals.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c3-locals.tf @@ -1,11 +1,11 @@ # Define Local Values in Terraform locals { - owners = var.business_divsion - environment = var.environment + owners = var.business_divsion + environment = var.environment resource_name_prefix = "${var.business_divsion}-${var.environment}" #name = "${local.owners}-${local.environment}" common_tags = { - owners = local.owners + owners = local.owners environment = local.environment } } \ No newline at end of file diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c4-random-resources.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c4-random-resources.tf index b599262..686c5b7 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c4-random-resources.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c4-random-resources.tf @@ -1,7 +1,7 @@ # Random String Resource resource "random_string" "myrandom" { - length = 6 - upper = false + length = 6 + upper = false special = false - number = false + number = false } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c5-resource-group.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c5-resource-group.tf index c3a7d70..261c58b 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c5-resource-group.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c5-resource-group.tf @@ -1,7 +1,7 @@ # Resource-1: Azure Resource Group resource "azurerm_resource_group" "rg" { # name = "${local.resource_name_prefix}-${var.resource_group_name}" - name = "${local.resource_name_prefix}-${var.resource_group_name}-${random_string.myrandom.id}" + name = "${local.resource_name_prefix}-${var.resource_group_name}-${random_string.myrandom.id}" location = var.resource_group_location - tags = local.common_tags + tags = local.common_tags } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-01-vnet-input-variables.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-01-vnet-input-variables.tf index 3430643..f1a4607 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-01-vnet-input-variables.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-01-vnet-input-variables.tf @@ -3,69 +3,69 @@ ## Virtual Network variable "vnet_name" { description = "Virtual Network name" - type = string - default = "vnet-default" + type = string + default = "vnet-default" } variable "vnet_address_space" { description = "Virtual Network address_space" - type = list(string) - default = ["10.0.0.0/16"] + type = list(string) + default = ["10.0.0.0/16"] } # Web Subnet Name variable "web_subnet_name" { description = "Virtual Network Web Subnet Name" - type = string - default = "websubnet" + type = string + default = "websubnet" } # Web Subnet Address Space variable "web_subnet_address" { description = "Virtual Network Web Subnet Address Spaces" - type = list(string) - default = ["10.0.1.0/24"] + type = list(string) + default = ["10.0.1.0/24"] } # App Subnet Name variable "app_subnet_name" { description = "Virtual Network App Subnet Name" - type = string - default = "appsubnet" + type = string + default = "appsubnet" } # App Subnet Address Space variable "app_subnet_address" { description = "Virtual Network App Subnet Address Spaces" - type = list(string) - default = ["10.0.11.0/24"] + type = list(string) + default = ["10.0.11.0/24"] } # Database Subnet Name variable "db_subnet_name" { description = "Virtual Network Database Subnet Name" - type = string - default = "dbsubnet" + type = string + default = "dbsubnet" } # Database Subnet Address Space variable "db_subnet_address" { description = "Virtual Network Database Subnet Address Spaces" - type = list(string) - default = ["10.0.21.0/24"] + type = list(string) + default = ["10.0.21.0/24"] } # Bastion / Management Subnet Name variable "bastion_subnet_name" { description = "Virtual Network Bastion Subnet Name" - type = string - default = "bastionsubnet" + type = string + default = "bastionsubnet" } # Bastion / Management Subnet Address Space variable "bastion_subnet_address" { description = "Virtual Network Bastion Subnet Address Spaces" - type = list(string) - default = ["10.0.100.0/24"] + type = list(string) + default = ["10.0.100.0/24"] } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-02-virtual-network.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-02-virtual-network.tf index a10dd3c..2168469 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-02-virtual-network.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-02-virtual-network.tf @@ -4,7 +4,7 @@ resource "azurerm_virtual_network" "vnet" { address_space = var.vnet_address_space location = azurerm_resource_group.rg.location resource_group_name = azurerm_resource_group.rg.name - tags = local.common_tags + tags = local.common_tags } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-03-web-subnet-and-nsg.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-03-web-subnet-and-nsg.tf index 0a0b7f1..f95c9d0 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-03-web-subnet-and-nsg.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-03-web-subnet-and-nsg.tf @@ -3,7 +3,7 @@ resource "azurerm_subnet" "websubnet" { name = "${azurerm_virtual_network.vnet.name}-${var.web_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name - address_prefixes = var.web_subnet_address + address_prefixes = var.web_subnet_address } # Resource-2: Create Network Security Group (NSG) @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "web_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "web_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.web_nsg_rule_inbound] # Every NSG Rule Association will disassociate NSG from Subnet and Associate it, so we associate it only after NSG is completely created - Azure Provider Bug https://github.com/terraform-providers/terraform-provider-azurerm/issues/354 + depends_on = [azurerm_network_security_rule.web_nsg_rule_inbound] # Every NSG Rule Association will disassociate NSG from Subnet and Associate it, so we associate it only after NSG is completely created - Azure Provider Bug https://github.com/terraform-providers/terraform-provider-azurerm/issues/354 subnet_id = azurerm_subnet.websubnet.id network_security_group_id = azurerm_network_security_group.web_subnet_nsg.id } @@ -27,18 +27,18 @@ locals { "100" : "80", # If the key starts with a number, you must use the colon syntax ":" instead of "=" "110" : "443", "120" : "22" - } + } } ## NSG Inbound Rule for WebTier Subnets resource "azurerm_network_security_rule" "web_nsg_rule_inbound" { - for_each = local.web_inbound_ports_map + for_each = local.web_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-04-app-subnet-and-nsg.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-04-app-subnet-and-nsg.tf index cb560e1..f4bddb1 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-04-app-subnet-and-nsg.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-04-app-subnet-and-nsg.tf @@ -3,7 +3,7 @@ resource "azurerm_subnet" "appsubnet" { name = "${azurerm_virtual_network.vnet.name}-${var.app_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name - address_prefixes = var.app_subnet_address + address_prefixes = var.app_subnet_address } # Resource-2: Create Network Security Group (NSG) @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "app_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "app_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.app_nsg_rule_inbound] + depends_on = [azurerm_network_security_rule.app_nsg_rule_inbound] subnet_id = azurerm_subnet.appsubnet.id network_security_group_id = azurerm_network_security_group.app_subnet_nsg.id } @@ -28,18 +28,18 @@ locals { "110" : "443", "120" : "8080", "130" : "22" - } + } } ## NSG Inbound Rule for AppTier Subnets resource "azurerm_network_security_rule" "app_nsg_rule_inbound" { - for_each = local.app_inbound_ports_map + for_each = local.app_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-05-db-subnet-and-nsg.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-05-db-subnet-and-nsg.tf index 2e60aa8..2b0b05b 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-05-db-subnet-and-nsg.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-05-db-subnet-and-nsg.tf @@ -3,7 +3,7 @@ resource "azurerm_subnet" "dbsubnet" { name = "${azurerm_virtual_network.vnet.name}-${var.db_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name - address_prefixes = var.db_subnet_address + address_prefixes = var.db_subnet_address } # Resource-2: Create Network Security Group (NSG) @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "db_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "db_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.db_nsg_rule_inbound] + depends_on = [azurerm_network_security_rule.db_nsg_rule_inbound] subnet_id = azurerm_subnet.dbsubnet.id network_security_group_id = azurerm_network_security_group.db_subnet_nsg.id } @@ -27,18 +27,18 @@ locals { "100" : "3306", # If the key starts with a number, you must use the colon syntax ":" instead of "=" "110" : "1433", "120" : "5432" - } + } } ## NSG Inbound Rule for DBTier Subnets resource "azurerm_network_security_rule" "db_nsg_rule_inbound" { - for_each = local.db_inbound_ports_map + for_each = local.db_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf index 837e89e..04c59a9 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-06-bastion-subnet-and-nsg.tf @@ -1,6 +1,6 @@ # Resource-1: Create Bastion / Management Subnet resource "azurerm_subnet" "bastionsubnet" { - name = "${azurerm_virtual_network.vnet.name}-${var.bastion_subnet_name}" + name = "${azurerm_virtual_network.vnet.name}-${var.bastion_subnet_name}" resource_group_name = azurerm_resource_group.rg.name virtual_network_name = azurerm_virtual_network.vnet.name address_prefixes = var.bastion_subnet_address @@ -15,7 +15,7 @@ resource "azurerm_network_security_group" "bastion_subnet_nsg" { # Resource-3: Associate NSG and Subnet resource "azurerm_subnet_network_security_group_association" "bastion_subnet_nsg_associate" { - depends_on = [ azurerm_network_security_rule.bastion_nsg_rule_inbound] + depends_on = [azurerm_network_security_rule.bastion_nsg_rule_inbound] subnet_id = azurerm_subnet.bastionsubnet.id network_security_group_id = azurerm_network_security_group.bastion_subnet_nsg.id } @@ -26,18 +26,18 @@ locals { bastion_inbound_ports_map = { "100" : "22", # If the key starts with a number, you must use the colon syntax ":" instead of "=" "110" : "3389" - } + } } ## NSG Inbound Rule for Bastion / Management Subnets resource "azurerm_network_security_rule" "bastion_nsg_rule_inbound" { - for_each = local.bastion_inbound_ports_map + for_each = local.bastion_inbound_ports_map name = "Rule-Port-${each.value}" priority = each.key direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" - destination_port_range = each.value + destination_port_range = each.value source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-07-vnet-outputs.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-07-vnet-outputs.tf index 8c84557..398909e 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-07-vnet-outputs.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c6-07-vnet-outputs.tf @@ -2,36 +2,36 @@ ## Virtual Network Name output "virtual_network_name" { description = "Virtual Network Name" - value = azurerm_virtual_network.vnet.name + value = azurerm_virtual_network.vnet.name } ## Virtual Network ID output "virtual_network_id" { description = "Virtual Network ID" - value = azurerm_virtual_network.vnet.id + value = azurerm_virtual_network.vnet.id } # Subnet Outputs (We will write for one web subnet and rest all we will ignore for now) ## Subnet Name output "web_subnet_name" { description = "WebTier Subnet Name" - value = azurerm_subnet.websubnet.name + value = azurerm_subnet.websubnet.name } ## Subnet ID output "web_subnet_id" { description = "WebTier Subnet ID" - value = azurerm_subnet.websubnet.id + value = azurerm_subnet.websubnet.id } # Network Security Outputs ## Web Subnet NSG Name output "web_subnet_nsg_name" { description = "WebTier Subnet NSG Name" - value = azurerm_network_security_group.web_subnet_nsg.name + value = azurerm_network_security_group.web_subnet_nsg.name } ## Web Subnet NSG ID output "web_subnet_nsg_id" { description = "WebTier Subnet NSG ID" - value = azurerm_network_security_group.web_subnet_nsg.id + value = azurerm_network_security_group.web_subnet_nsg.id } diff --git a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c7-05-web-linuxvm-resource.tf b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c7-05-web-linuxvm-resource.tf index 736e32b..50a0257 100644 --- a/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c7-05-web-linuxvm-resource.tf +++ b/15-Azure-Standard-LoadBalancer-Inbound-NATRules/terraform-manifests/c7-05-web-linuxvm-resource.tf @@ -1,6 +1,6 @@ # Locals Block for custom data locals { -webvm_custom_data = <