-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add `os_login` resource to securely SSH into VM instance created by the Terraform IaC template - Update docs to include information on how to add and use SSH keys Fixes issues #10 #1
- Loading branch information
1 parent
b291c02
commit c34d8d8
Showing
13 changed files
with
93 additions
and
41 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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
variable "folder_name" {} | ||
variable "org_id" {} | ||
variable "dev_folder_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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
output "public_subnet_name" { | ||
value = google_compute_subnetwork.public_subnet.name | ||
output "static_ip" { | ||
value = google_compute_address.static_ip.address | ||
} |
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/resources/os_login_ssh_public_key | ||
data "google_client_openid_userinfo" "me" {} | ||
|
||
# Add public ssh key to IAM user | ||
resource "google_os_login_ssh_public_key" "cache" { | ||
user = data.google_client_openid_userinfo.me.email | ||
key = file("~/.ssh/gcp-compute.pub") | ||
} | ||
|
||
# Allow IAM user to use OS Login | ||
# If you are project owner or editor, this role is configured automatically. | ||
resource "google_project_iam_member" "project" { | ||
project = var.project_id | ||
role = "roles/compute.osAdminLogin" | ||
member = "user:${data.google_client_openid_userinfo.me.email}" | ||
} |
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 @@ | ||
variable "project_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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
variable "region" {} | ||
variable "project_name" {} | ||
variable "project_id" {} | ||
# variable "folder_name" {} | ||
variable "org_id" {} | ||
variable "billing_account_id" {} | ||
variable "gke_folder_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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
variable "vm_name" {} | ||
variable "vpc_name" {} | ||
variable "machine_type" {} | ||
variable "region" {} | ||
variable "zone" {} | ||
variable "subnetwork" {} | ||
variable "subnet_name" {} | ||
variable "static_ip" {} |
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 |
---|---|---|
@@ -1,74 +1,75 @@ | ||
variable "region" { | ||
description = "VPC region" | ||
default = "us-east1" | ||
type = string | ||
description = "VPC region" | ||
} | ||
|
||
variable "dev_folder_id" { | ||
description = "Dev folder ID in organization" | ||
default = "135331753386" | ||
type = string | ||
description = "Dev folder ID in organization" | ||
} | ||
|
||
variable "folder_name" { | ||
description = "GCP organization folder name" | ||
default = "test-folder" | ||
type = string | ||
description = "GCP organization folder name" | ||
} | ||
|
||
variable "project_name" { | ||
description = "GCP project display name" | ||
default = "tf-gcp-org" | ||
type = string | ||
description = "GCP project display name" | ||
} | ||
|
||
# Follows regex: /^[a-z][-a-z0-9]{4,28}[a-z0-9]{1}$/gm | ||
variable "project_id" { | ||
description = "GCP Project ID" | ||
default = "tf-gcp-org-id" | ||
type = string | ||
description = "must be between 6 and 30 characters and can have lowercase letters, digits, or hyphens.It must start with a lowercase letter and end with a letter or number." | ||
} | ||
|
||
variable "org_id" { | ||
description = "The numeric ID of the organization this project belongs to" | ||
type = string | ||
description = "The numeric ID of the organization this project belongs to" | ||
} | ||
|
||
variable "billing_account_id" { | ||
description = "The alphanumeric ID of the billing account this project belongs to" | ||
type = string | ||
description = "The alphanumeric ID of the billing account this project belongs to" | ||
} | ||
|
||
variable "api_names" { | ||
description = "list of apis to enable" | ||
type = list(string) | ||
description = "list of apis to enable" | ||
} | ||
|
||
variable "vpc_name" { | ||
description = "VPC name" | ||
type = string | ||
description = "VPC name" | ||
} | ||
|
||
variable "subnet_cidr" { | ||
description = "list of subnet cidr" | ||
type = list(string) | ||
description = "list of subnet cidr" | ||
} | ||
|
||
variable "subnet_name" { | ||
description = "Subnet name" | ||
type = string | ||
description = "Subnet name" | ||
} | ||
|
||
variable "vm_name" { | ||
description = "VM name" | ||
type = string | ||
description = "VM name" | ||
} | ||
|
||
variable "machine_type" { | ||
description = "VM name" | ||
type = string | ||
description = "VM name" | ||
} | ||
|
||
variable "zone" { | ||
description = "Zone name" | ||
type = string | ||
description = "Zone name" | ||
} |