mirror of
https://github.com/ghndrx/tf-variable-demo.git
synced 2026-02-10 06:54:57 +00:00
commit new files
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
credentials.json
|
||||
@@ -0,0 +1,9 @@
|
||||
resource "google_compute_instance_group_manager" "instance_group" {
|
||||
name = "instance-group"
|
||||
project = var.project_id
|
||||
region = var.region
|
||||
base_instance_name = "instance"
|
||||
instance_template = var.template_self_link
|
||||
target_size = 2
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
output "self_link" {
|
||||
value = google_compute_instance_group_manager.instance_group.instance_group
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
variable "project_id" {}
|
||||
variable "region" {}
|
||||
variable "template_self_link" {}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
resource "google_compute_instance_template" "template" {
|
||||
name_prefix = "instance-template-"
|
||||
project = var.project_id
|
||||
region = var.region
|
||||
|
||||
machine_type = var.instance_type
|
||||
disk {
|
||||
source_image = var.image_name
|
||||
auto_delete = true
|
||||
boot = true
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config {
|
||||
// Ephemeral public IP address
|
||||
}
|
||||
}
|
||||
|
||||
metadata_startup_script = var.startup_script
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
variable "project_id" {}
|
||||
variable "region" {}
|
||||
variable "image_name" {}
|
||||
variable "instance_type" {}
|
||||
variable "startup_script" {}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
resource "google_compute_backend_service" "backend_service" {
|
||||
name = "backend-service"
|
||||
project = var.project_id
|
||||
region = var.region
|
||||
|
||||
backend {
|
||||
group = var.backend_instance_group_self_link
|
||||
}
|
||||
|
||||
health_checks = [google_compute_health_check.default_http.self_link]
|
||||
}
|
||||
|
||||
resource "google_compute_health_check" "default_http" {
|
||||
name = "default-http-health-check"
|
||||
project = var.project_id
|
||||
check_interval_sec = 30
|
||||
timeout_sec = 5
|
||||
http_health_check {
|
||||
port = 80
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "url_map" {
|
||||
name = "url-map"
|
||||
project = var.project_id
|
||||
default_service = google_compute_backend_service.backend_service.self_link
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "http_proxy" {
|
||||
name = "http-proxy"
|
||||
project = var.project_id
|
||||
url_map = google_compute_url_map.url_map.self_link
|
||||
}
|
||||
|
||||
resource "google_compute_global_forwarding_rule" "forwarding_rule" {
|
||||
name = "forwarding-rule"
|
||||
project = var.project_id
|
||||
target = google_compute_target_http_proxy.http_proxy.self_link
|
||||
port_range = "80"
|
||||
ip_address = google_compute_global_address.lb_address.address
|
||||
}
|
||||
|
||||
resource "google_compute_global_address" "lb_address" {
|
||||
name = "lb-address"
|
||||
project = var.project_id
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
credentials_file = "path/to/credentials.json"
|
||||
credentials_file = "credentials.json"
|
||||
project_id = "terraform-demo-382210"
|
||||
region = "us-central1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
Reference in New Issue
Block a user