diff --git a/terraform/auth/sapient-tfadmin.json b/terraform/auth/learning-tfadmin.json similarity index 100% rename from terraform/auth/sapient-tfadmin.json rename to terraform/auth/learning-tfadmin.json diff --git a/terraform/backend.tf b/terraform/backend.tf index eea6c60..2389d43 100644 --- a/terraform/backend.tf +++ b/terraform/backend.tf @@ -1,7 +1,7 @@ terraform { required_version = ">= 0.12" backend "gcs" { - bucket = "junaid-demo" - prefix = "terraform-abdul" + bucket = "learning-terraform" + prefix = "terraform-state" } } diff --git a/terraform/lb-managed.tf b/terraform/lb-managed.tf index 04cb9a1..daee3ca 100644 --- a/terraform/lb-managed.tf +++ b/terraform/lb-managed.tf @@ -5,7 +5,7 @@ resource "google_compute_global_forwarding_rule" "global_forwarding_rule" { name = "${var.app_name}-${var.app_environment}-global-forwarding-rule" project = var.gcp_project target = google_compute_target_http_proxy.target_http_proxy.self_link - port_range = "8080" + port_range = "80" } # used by one or more global forwarding rule to route incoming HTTP requests to a URL map @@ -42,7 +42,7 @@ resource "google_compute_instance_group_manager" "web_private_group" { } named_port { name = "http" - port = 8080 + port = 80 } } @@ -52,7 +52,7 @@ resource "google_compute_health_check" "healthcheck" { timeout_sec = 1 check_interval_sec = 1 http_health_check { - port = 8080 + port = 80 } } diff --git a/terraform/network-firewall.tf b/terraform/network-firewall.tf index aa1eb5d..497be26 100644 --- a/terraform/network-firewall.tf +++ b/terraform/network-firewall.tf @@ -6,7 +6,7 @@ resource "google_compute_firewall" "allow-http" { network = "${google_compute_network.vpc.name}" allow { protocol = "tcp" - ports = ["8080"] + ports = ["80"] } source_ranges = ["0.0.0.0/0"] target_tags = ["http"] diff --git a/terraform/network.tf b/terraform/network.tf index c1e4f03..d0917c2 100644 --- a/terraform/network.tf +++ b/terraform/network.tf @@ -9,7 +9,7 @@ resource "google_compute_network" "vpc" { # create private subnet resource "google_compute_subnetwork" "private_subnet_1" { - provider = google-beta + provider = "google-beta" purpose = "PRIVATE" name = "${var.app_name}-${var.app_environment}-private-subnet-1" ip_cidr_range = var.private_subnet_cidr_1 @@ -19,8 +19,8 @@ resource "google_compute_subnetwork" "private_subnet_1" { # create a public ip for nat service resource "google_compute_address" "nat_ip" { - name = "${var.app_name}-${var.app_environment}-nat-ip" - project = var.gcp_project + name = "${var.app_name}-${var.app_environment}-nap-ip" + project = var.app_project region = var.gcp_region_1 } @@ -62,4 +62,4 @@ resource "google_compute_firewall" "allow-internal" { source_ranges = [ "${var.private_subnet_cidr_1}" ] -} +} \ No newline at end of file diff --git a/terraform/terraform.tfvars b/terraform/terraform.tfvars index 056e26d..178cbbc 100644 --- a/terraform/terraform.tfvars +++ b/terraform/terraform.tfvars @@ -1,20 +1,20 @@ # Application Definition -app_name = "sapient" #do NOT enter any spaces +app_name = "learning" #do NOT enter any spaces app_environment = "develop" # Dev, Test, Prod, etc -app_domain = "sapient-webserver.com" -#app_project = "sapient" +app_domain = "learning-webserver.com" +#app_project = "learning" app_node_count = 2 # GCP Settings -gcp_project = "internal-interview-candidates" +gcp_project = "dark-airway-363408" gcp_region_1 = "europe-west1" gcp_zone_1 = "europe-west1-b" -gcp_auth_file = "auth/sapient-tfadmin.json" +gcp_auth_file = "auth/learning-tfadmin.json" # GCP Netwok private_subnet_cidr_1 = "10.10.1.0/24" # Bucket -bucket-name = "interview-abdul" +bucket-name = "learning-terrform" storage-class = "REGIONAL" diff --git a/terraform/variables-auth.tf b/terraform/variables-auth.tf index bb4b6b9..c06b632 100644 --- a/terraform/variables-auth.tf +++ b/terraform/variables-auth.tf @@ -6,7 +6,7 @@ variable "gcp_auth_file" { description = "GCP authentication file" } -# define GCP project name +# define GCP project names #variable "app_project" { # type = string # description = "GCP project name" diff --git a/terraform/vm.tf b/terraform/vm.tf index a78a755..3483f81 100644 --- a/terraform/vm.tf +++ b/terraform/vm.tf @@ -29,5 +29,5 @@ resource "google_compute_instance_template" "web_server" { create_before_destroy = true } - metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential apache2; sudo sed -i 's/80/8080/g' /etc/apache2/ports.conf; sudo service apache2 restart" -} + metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential apache2" +} \ No newline at end of file