Created
May 29, 2019 20:27
-
-
Save trigun117/7fc3047727eee638d52087c621932cae to your computer and use it in GitHub Desktop.
Terraform configuration for create GCP instance
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
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