Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated terraform configs #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions terraform/backend.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_version = ">= 0.12"
backend "gcs" {
bucket = "junaid-demo"
prefix = "terraform-abdul"
bucket = "learning-terraform"
prefix = "terraform-state"
}
}
6 changes: 3 additions & 3 deletions terraform/lb-managed.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,7 +42,7 @@ resource "google_compute_instance_group_manager" "web_private_group" {
}
named_port {
name = "http"
port = 8080
port = 80
}
}

Expand All @@ -52,7 +52,7 @@ resource "google_compute_health_check" "healthcheck" {
timeout_sec = 1
check_interval_sec = 1
http_health_check {
port = 8080
port = 80
}
}

Expand Down
2 changes: 1 addition & 1 deletion terraform/network-firewall.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 4 additions & 4 deletions terraform/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -62,4 +62,4 @@ resource "google_compute_firewall" "allow-internal" {
source_ranges = [
"${var.private_subnet_cidr_1}"
]
}
}
12 changes: 6 additions & 6 deletions terraform/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -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"

2 changes: 1 addition & 1 deletion terraform/variables-auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions terraform/vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}