Created
March 2, 2017 15:09
-
-
Save ryane/392c1565d83c63df851d1be36b2f4a8a to your computer and use it in GitHub Desktop.
google compute instance with 2 disks: http://stackoverflow.com/questions/42169895/what-is-the-correct-way-to-add-a-second-disk-using-terraform-on-google-compute
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
variable "image_url" { | |
default = "debian-cloud/debian-8" | |
} | |
resource "google_compute_disk" "seconddisk" { | |
name = "seconddisk" | |
type = "pd-standard" | |
zone = "us-west1-a" | |
size = "100" | |
} | |
resource "google_compute_instance" "someinstance" { | |
name = "someinstance" | |
machine_type = "n1-standard-4" | |
zone = "us-west1-a" | |
disk { | |
image = "${var.image_url}" | |
} | |
disk { | |
disk = "${google_compute_disk.seconddisk.name}" | |
} | |
network_interface { | |
network = "default" | |
access_config = {} | |
} | |
} |
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
$ terraform apply | |
google_compute_disk.seconddisk: Creating... | |
disk_encryption_key_sha256: "" => "<computed>" | |
name: "" => "seconddisk" | |
self_link: "" => "<computed>" | |
size: "" => "100" | |
type: "" => "pd-standard" | |
zone: "" => "us-west1-a" | |
google_compute_disk.seconddisk: Still creating... (10s elapsed) | |
google_compute_disk.seconddisk: Creation complete | |
google_compute_instance.someinstance: Creating... | |
can_ip_forward: "" => "false" | |
create_timeout: "" => "4" | |
disk.#: "" => "2" | |
disk.0.auto_delete: "" => "true" | |
disk.0.disk_encryption_key_sha256: "" => "<computed>" | |
disk.0.image: "" => "debian-cloud/debian-8" | |
disk.1.auto_delete: "" => "true" | |
disk.1.disk: "" => "seconddisk" | |
disk.1.disk_encryption_key_sha256: "" => "<computed>" | |
machine_type: "" => "n1-standard-4" | |
metadata_fingerprint: "" => "<computed>" | |
name: "" => "someinstance" | |
network_interface.#: "" => "1" | |
network_interface.0.access_config.#: "" => "1" | |
network_interface.0.access_config.0.assigned_nat_ip: "" => "<computed>" | |
network_interface.0.address: "" => "<computed>" | |
network_interface.0.name: "" => "<computed>" | |
network_interface.0.network: "" => "default" | |
self_link: "" => "<computed>" | |
tags_fingerprint: "" => "<computed>" | |
zone: "" => "us-west1-a" | |
google_compute_instance.someinstance: Still creating... (10s elapsed) | |
google_compute_instance.someinstance: Creation complete | |
Apply complete! Resources: 2 added, 0 changed, 0 destroyed. | |
The state of your infrastructure has been saved to the path | |
below. This state is required to modify and destroy your | |
infrastructure, so keep it safe. To inspect the complete state | |
use the `terraform show` command. | |
State path: terraform.tfstate | |
$ gcloud compute instances describe someinstance --zone=us-west1-a --format json | jq '.disks|length' | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment