gpt4 book ai didi

google-cloud-platform - Terraform:将文件复制到 GCP 计算实例

转载 作者:行者123 更新时间:2023-12-04 01:48:47 25 4
gpt4 key购买 nike

这肯定不会那么复杂吧?我尝试了多种方法,但都失败了。

只需使用 file provisioner本来是最简单的选择,但无济于事。问题是,计算实例没有配置为标准的密码,也没有 key 。

因此,这导致我尝试这样的事情:

resource "google_compute_instance" "test-build" {
...
metadata {
ssh-keys = "jon:${file("./gcloud_instance.pub")}"
}
...

provisioner "file" {
source = "test/test_file"
destination = "/tmp/test_file.txt"

connection {
type = "ssh"
private_key = "${file("./gcloud_instance")}"
agent = "false"
}
}

再次,无济于事。 (仅供引用, key 对是我创建的,我确认公钥正在被推送到计算实例)

我什至尝试将其拆分为模块,然后一个接一个地运行.. 但似乎我们不能在 null_resource 中使用文件提供程序。所以这也行不通。

有没有人找到一种有效地做到这一点的方法?

最佳答案

取消它,我解决了..如果我添加用户会有所帮助!回答这个问题,而不是删除它,因为我在网上找不到很多像这样的例子,所以它可能对其他人有用。

resource "google_compute_instance" "test-build" {
project = "artifactory-staging"
name = "file-transfer-test"
machine_type = "n1-standard-2"
zone = "europe-west3-b"
allow_stopping_for_update = "true"

boot_disk {
initialize_params {
image = "centos-7-v20181210"
}
}
network_interface {
subnetwork = "default"
subnetwork_project = "artifactory-staging"
access_config = {}
}
metadata {
ssh-keys = "jon:${file("./creds/gcloud_instance.pub")}"
}

provisioner "file" {
source = "creds/test_file"
destination = "/tmp/test_file"

connection {
type = "ssh"
user = "jon"
private_key = "${file("./creds/gcloud_instance")}"
agent = "false"
}
}
}

关于google-cloud-platform - Terraform:将文件复制到 GCP 计算实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54231950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com