【发布时间】:2021-09-13 07:04:25
【问题描述】:
我有一个 terraform 脚本
resource "google_compute_attached_disk" "default3" {
disk = google_compute_disk.default2.id
instance = google_compute_instance.default.id
}
resource "google_compute_instance" "default" {
name = "test"
machine_type = "custom-8-16384"
zone = "asia-south1-a"
tags = ["foo", "bar"]
boot_disk {
initialize_params {
image = "centos-cloud/centos-7"
}
}
network_interface {
network = "default"
access_config {
}
}
metadata_startup_script = <<-EOF
echo "hello
you" > /test.txt
echo "help
me" > /test2.txt
EOF
lifecycle {
ignore_changes = [attached_disk]
}
}
resource "google_compute_disk" "default2" {
name = "test-disk"
type = "pd-balanced"
zone = "asia-south1-a"
image = "centos-7-v20210609"
size = 100
}
现在我想运行 metadata_startup_script,但它不会执行。创建资源但不执行脚本。我怎样才能运行这个脚本? 基本上我有一个很大的 bash 脚本。如何在 GCP 机器上运行此脚本?
【问题讨论】:
标签: google-cloud-platform terraform terraform-provider-gcp