Skip to content

Instantly share code, notes, and snippets.

@trigun117
Created May 29, 2019 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trigun117/7fc3047727eee638d52087c621932cae to your computer and use it in GitHub Desktop.
Save trigun117/7fc3047727eee638d52087c621932cae to your computer and use it in GitHub Desktop.
Terraform configuration for create GCP instance
provider "google" {
credentials = "${file("credentials.json")}"
project = "project"
region = "us-central1"
}
resource "google_compute_instance" "gcp_instance" {
count = 1
name = "test-instance-${count.index}"
machine_type = "f1-micro"
zone = "us-west1-a"
tags = ["http-server", "https-server"]
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
network_interface {
network = "default"
access_config {}
}
metadata = {
sshKeys = "username:${file("~/.ssh/id_rsa.pub")}"
}
metadata_startup_script = "sudo apt update && sudo apt upgrade -y"
}
output "ip" {
value = "${google_compute_instance.gcp_instance.*.network_interface.0.access_config.0.nat_ip}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment