forked from antonputra/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
How To SSH into your VM? - Google Cloud Platform (antonputra#88)
- Loading branch information
1 parent
a712f11
commit ca53b8d
Showing
9 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# How To SSH into your VM? - Google Cloud Platform (GCP | IAP tunnel | OS Login | Audit | Google IAM) | ||
|
||
You can find tutorial [here](https://antonputra.com/google/gcp-how-to-ssh-into-your-vm/). |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
locals { | ||
project_id = "lesson-120" | ||
region = "us-central1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs | ||
provider "google" { | ||
project = local.project_id | ||
region = local.region | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 4.31.0" | ||
} | ||
} | ||
|
||
required_version = "~> 1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_service | ||
resource "google_project_service" "compute" { | ||
service = "compute.googleapis.com" | ||
|
||
disable_on_destroy = false | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network | ||
resource "google_compute_network" "main" { | ||
name = "main" | ||
routing_mode = "REGIONAL" | ||
auto_create_subnetworks = false | ||
delete_default_routes_on_create = true | ||
|
||
depends_on = [google_project_service.compute] | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route | ||
resource "google_compute_route" "default_to_internet" { | ||
name = "default-internet-gateway" | ||
dest_range = "0.0.0.0/0" | ||
network = google_compute_network.main.name | ||
next_hop_gateway = "default-internet-gateway" | ||
priority = 1000 | ||
description = "Default route to the Internet." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_subnetwork | ||
resource "google_compute_subnetwork" "private" { | ||
name = "private" | ||
region = local.region | ||
ip_cidr_range = "10.0.0.0/18" | ||
stack_type = "IPV4_ONLY" | ||
network = google_compute_network.main.id | ||
private_ip_google_access = true | ||
} | ||
|
||
resource "google_compute_subnetwork" "public" { | ||
name = "public" | ||
region = local.region | ||
ip_cidr_range = "10.0.64.0/18" | ||
stack_type = "IPV4_ONLY" | ||
network = google_compute_network.main.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router | ||
resource "google_compute_router" "router" { | ||
name = "router" | ||
region = local.region | ||
network = google_compute_network.main.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_address | ||
resource "google_compute_address" "nat" { | ||
name = "nat" | ||
address_type = "EXTERNAL" | ||
network_tier = "PREMIUM" | ||
|
||
depends_on = [google_project_service.compute] | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router_nat | ||
resource "google_compute_router_nat" "nat" { | ||
name = "nat" | ||
router = google_compute_router.router.name | ||
region = local.region | ||
|
||
source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS" | ||
nat_ip_allocate_option = "MANUAL_ONLY" | ||
|
||
subnetwork { | ||
name = google_compute_subnetwork.private.id | ||
source_ip_ranges_to_nat = ["ALL_IP_RANGES"] | ||
} | ||
|
||
nat_ips = [google_compute_address.nat.self_link] | ||
} |