From 647eabdd412d03d97cc4b72aa8de69d3246b5e8a Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 05:48:30 -0400 Subject: [PATCH 01/10] UPDATE with new rules --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) 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/ From ee2c4f1f42283fa955bae7fba47c67ef0d664f6c Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 05:50:13 -0400 Subject: [PATCH 02/10] UPDATE terraform fmt --- .../top-level-blocks-samples.tf | 4 +- .../terraform-manifests/c1-versions.tf | 2 +- .../terraform-manifests/c1-versions.tf | 8 +- .../c2-generic-input-variables.tf | 16 +-- .../terraform-manifests/c3-locals.tf | 6 +- .../c4-random-resources.tf | 6 +- .../terraform-manifests/c5-resource-group.tf | 4 +- .../c6-01-vnet-input-variables.tf | 40 +++--- .../c6-02-virtual-network.tf | 2 +- .../c6-03-web-subnet-and-nsg.tf | 10 +- .../c6-04-app-subnet-and-nsg.tf | 10 +- .../c6-05-db-subnet-and-nsg.tf | 10 +- .../c6-06-bastion-subnet-and-nsg.tf | 10 +- .../terraform-manifests/c6-07-vnet-outputs.tf | 12 +- .../terraform-manifests/terraform.tfvars | 18 +-- .../terraform-manifests/c1-versions.tf | 12 +- .../c2-generic-input-variables.tf | 16 +-- .../terraform-manifests/c3-locals.tf | 6 +- .../c4-random-resources.tf | 6 +- .../terraform-manifests/c5-resource-group.tf | 4 +- .../c6-01-vnet-input-variables.tf | 40 +++--- .../c6-02-virtual-network.tf | 2 +- .../c6-03-web-subnet-and-nsg.tf | 10 +- .../c6-04-app-subnet-and-nsg.tf | 10 +- .../c6-05-db-subnet-and-nsg.tf | 10 +- .../c6-06-bastion-subnet-and-nsg.tf | 10 +- .../terraform-manifests/c6-07-vnet-outputs.tf | 12 +- .../c7-05-web-linuxvm-resource.tf | 24 ++-- .../c7-06-web-linuxvm-outputs.tf | 10 +- .../c8-01-bastion-host-input-variables.tf | 4 +- .../c8-02-bastion-host-linuxvm.tf | 24 ++-- .../c8-03-move-ssh-key-to-bastion-host.tf | 12 +- .../c8-05-bastion-outputs.tf | 2 +- .../c9-02-web-loadbalancer-resource.tf | 30 ++--- .../c9-03-web-loadbalancer-outputs.tf | 6 +- ...9-04-web-loadbalancer-inbound-nat-rules.tf | 20 +-- .../terraform-manifests/terraform.tfvars | 20 +-- .../terraform-manifests/c1-versions.tf | 12 +- .../c2-generic-input-variables.tf | 16 +-- .../terraform-manifests/c3-locals.tf | 6 +- .../c4-random-resources.tf | 6 +- .../terraform-manifests/c5-resource-group.tf | 4 +- .../c6-01-vnet-input-variables.tf | 48 ++++---- .../c6-02-virtual-network.tf | 2 +- .../c6-03-web-subnet-and-nsg.tf | 10 +- .../c6-04-app-subnet-and-nsg.tf | 10 +- .../c6-05-db-subnet-and-nsg.tf | 10 +- .../c6-06-bastion-subnet-and-nsg.tf | 10 +- .../c6-07-ag-subnet-and-nsg.tf | 10 +- .../terraform-manifests/c6-08-vnet-outputs.tf | 12 +- .../c7-01-web-linux-vmss-input-variables.tf | 8 +- ...02-web-linux-vmss-app1-nsg-inline-basic.tf | 2 +- .../c7-03-web-linux-vmss-app1-resource.tf | 24 ++-- ...x-vmss-app1-autoscaling-default-profile.tf | 58 ++++----- ...05-web-linux-vmss-app2-nsg-inline-basic.tf | 2 +- .../c7-06-web-linux-vmss-app2-resource.tf | 24 ++-- ...x-vmss-app2-autoscaling-default-profile.tf | 58 ++++----- .../c7-08-web-linux-vmss-outputs.tf | 4 +- .../c9-02-application-gateway-resource.tf | 92 +++++++------- .../c9-03-application-gateway-outputs.tf | 8 +- .../terraform-manifests/terraform.tfvars | 20 +-- .../terraform-manifests/c1-versions.tf | 12 +- .../c10-02-storage-account.tf | 4 +- .../c10-03-storage-account-outputs.tf | 4 +- .../c11-02-azure-key-vault-resource.tf | 28 ++--- .../c2-generic-input-variables.tf | 16 +-- .../terraform-manifests/c3-locals.tf | 6 +- .../c4-random-resources.tf | 6 +- .../terraform-manifests/c5-resource-group.tf | 4 +- .../c6-01-vnet-input-variables.tf | 48 ++++---- .../c6-02-virtual-network.tf | 2 +- .../c6-03-web-subnet-and-nsg.tf | 10 +- .../c6-04-app-subnet-and-nsg.tf | 10 +- .../c6-05-db-subnet-and-nsg.tf | 10 +- .../c6-06-bastion-subnet-and-nsg.tf | 10 +- .../c6-07-ag-subnet-and-nsg.tf | 10 +- .../terraform-manifests/c6-08-vnet-outputs.tf | 12 +- .../c7-01-web-linux-vmss-input-variables.tf | 4 +- .../c7-02-web-linux-vmss-nsg-inline-basic.tf | 2 +- .../c7-03-web-linux-vmss-resource.tf | 24 ++-- .../c7-04-web-linux-vmss-outputs.tf | 2 +- ...-linux-vmss-autoscaling-default-profile.tf | 60 ++++----- .../c9-02-application-gateway-resource.tf | 114 +++++++++--------- .../c9-03-application-gateway-outputs.tf | 8 +- ...04-application-gateway-managed-identity.tf | 2 +- .../terraform-manifests/terraform.tfvars | 20 +-- 86 files changed, 666 insertions(+), 666 deletions(-) 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/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 = < Date: Sat, 23 Jul 2022 05:50:39 -0400 Subject: [PATCH 03/10] ADD Github Actions files --- .github/dependabot.yml | 7 +++++++ .github/workflows/superlinter.yml | 24 ++++++++++++++++++++++++ .github/workflows/terraform.yml | 29 +++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/superlinter.yml create mode 100644 .github/workflows/terraform.yml 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..ef355ce --- /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 + with: + fetch-depth: 1 + - 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..3ab8a21 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,29 @@ +--- +name: "Code Quality: Terraform" +on: + push: + branches: + - main + pull_request: +jobs: + terraform: + name: Terraform + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + + - name: Run `terraform fmt` + id: fmt + run: terraform fmt -diff -check -no-color -recursive + - name: Run `terraform init` + id: init + run: terraform init + - name: Run `terraform validate` + id: validate + if: github.event_name == 'pull_request' + run: terraform validate -no-color \ No newline at end of file From b995045718cb1bf0f2f3acc8ad396148b2b3e3f7 Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 05:55:24 -0400 Subject: [PATCH 04/10] UPDATE disable validate --- .github/workflows/superlinter.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml index ef355ce..086ec57 100644 --- a/.github/workflows/superlinter.yml +++ b/.github/workflows/superlinter.yml @@ -14,11 +14,11 @@ jobs: - name: Lint Code uses: docker://github/super-linter:v4 env: - VALIDATE_ALL_CODEBASE: true + VALIDATE_ALL_CODEBASE: false 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 + VALIDATE_BASH: false + VALIDATE_JSON: false + VALIDATE_MD: false + VALIDATE_TERRAFORM: false + VALIDATE_YAML: false \ No newline at end of file From e529f3a4c7b7601e4b51620dc086b7906b3b5d3a Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 06:11:22 -0400 Subject: [PATCH 05/10] UPDATE terraform workflows --- .github/workflows/terraform.yml | 62 ++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 3ab8a21..ba03c88 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -10,20 +10,64 @@ jobs: name: Terraform runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Terraform uses: hashicorp/setup-terraform@v1 - - name: Run `terraform fmt` + - name: Terraform Format id: fmt - run: terraform fmt -diff -check -no-color -recursive - - name: Run `terraform init` + run: terraform fmt -check -recursive + + - name: Terraform Init id: init run: terraform init - - name: Run `terraform validate` + + - 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 + + - name: Update Pull Request + uses: actions/github-script@6 if: github.event_name == 'pull_request' - run: terraform validate -no-color \ No newline at end of file + env: + PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` + +
Show Plan + + \`\`\`\n + ${process.env.PLAN} + \`\`\` + +
+ + *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: output + }) + + + - name: Terraform Plan Status + if: steps.plan.outcome == 'failure' + run: exit 1 + + - name: Terraform Apply + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: terraform apply -auto-approve -input=false \ No newline at end of file From 1777806cf0a048e88ba66f98fee30af91f155c41 Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 06:12:49 -0400 Subject: [PATCH 06/10] UPDATE terraform workflows --- .github/workflows/terraform.yml | 41 +-------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index ba03c88..550b5a7 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -31,43 +31,4 @@ jobs: - name: Terraform Plan id: plan run: terraform plan -no-color -input=false - continue-on-error: true - - - name: Update Pull Request - uses: actions/github-script@6 - if: github.event_name == 'pull_request' - env: - PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` - #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` - #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` - #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` - -
Show Plan - - \`\`\`\n - ${process.env.PLAN} - \`\`\` - -
- - *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; - - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: output - }) - - - - name: Terraform Plan Status - if: steps.plan.outcome == 'failure' - run: exit 1 - - - name: Terraform Apply - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - run: terraform apply -auto-approve -input=false \ No newline at end of file + continue-on-error: true \ No newline at end of file From 69203f8c3c1b244bd5b56551bf63f293789e793f Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 06:14:33 -0400 Subject: [PATCH 07/10] UPDATE terraform workflow fmt --- .github/workflows/terraform.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 550b5a7..ebe16f7 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -16,9 +16,9 @@ jobs: - name: Setup Terraform uses: hashicorp/setup-terraform@v1 - - name: Terraform Format - id: fmt - run: terraform fmt -check -recursive +# - name: Terraform Format +# id: fmt +# run: terraform fmt -check -recursive - name: Terraform Init id: init From 24abd3e96f2ec36e8ff72285489ecdedfe3ee0ea Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 06:19:12 -0400 Subject: [PATCH 08/10] UPDATE terraform workflows --- .github/workflows/terraform.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index ebe16f7..2831aff 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -10,6 +10,7 @@ jobs: name: Terraform runs-on: ubuntu-latest steps: + - name: Checkout uses: actions/checkout@v3 @@ -28,7 +29,7 @@ jobs: 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 +# - name: Terraform Plan +# id: plan +# run: terraform plan -no-color -input=false +# continue-on-error: true \ No newline at end of file From ba20dfb2d75e3d0c11352185037f6c463ced8895 Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 06:22:46 -0400 Subject: [PATCH 09/10] ADD azurerm_network_watcher.default --- .../terraform-manifests/nwwatcher.tf | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 10-Azure-Virtual-Network-4Tier/terraform-manifests/nwwatcher.tf 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 From 9e5e6763fbe5d3f454fd0eff43bbd7d0044330fd Mon Sep 17 00:00:00 2001 From: Jose Almenarez Date: Sat, 23 Jul 2022 06:24:30 -0400 Subject: [PATCH 10/10] UPDATE workflow superlinter --- .github/workflows/superlinter.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml index 086ec57..523ff46 100644 --- a/.github/workflows/superlinter.yml +++ b/.github/workflows/superlinter.yml @@ -7,18 +7,18 @@ jobs: name: Super-Linter runs-on: ubuntu-latest steps: + - name: Checkout Repository uses: actions/checkout@v3 - with: - fetch-depth: 1 + - name: Lint Code uses: docker://github/super-linter:v4 env: - VALIDATE_ALL_CODEBASE: false + VALIDATE_ALL_CODEBASE: true DEFAULT_BRANCH: "main" DISABLE_ERRORS: false - VALIDATE_BASH: false - VALIDATE_JSON: false - VALIDATE_MD: false - VALIDATE_TERRAFORM: false - VALIDATE_YAML: false \ No newline at end of file + VALIDATE_BASH: true + VALIDATE_JSON: true + VALIDATE_MD: true + VALIDATE_TERRAFORM: true + VALIDATE_YAML: true \ No newline at end of file