gpt4 book ai didi

terraform - 使用 terraform 在 digitalOcean 中使用 droplet 进行卷连接

转载 作者:行者123 更新时间:2023-12-04 15:45:26 24 4
gpt4 key购买 nike

我正在尝试在 digitalocean 提供程序中使用 terraform 附加一个带有 droplet 的卷。我能够创建液滴和体积。但是,当我尝试使用 Droplet 附加卷时,出现了错误。

下面是我的代码:

    provider "digitalocean" {
token = "${var.do_token}"
}
resource "digitalocean_volume" "web" {
region = "nyc1"
name = "baz"
size = 10
initial_filesystem_type = "ext4"
description = "First volume for testing 10 GB"
}

resource "digitalocean_droplet" "web" {
name = "web"
size = "${var.size}"
image = "${var.image}"
region = "${var.region}"
ssh_keys = [23625200]
private_networking = "true"
connection {
user = "root"
type = "ssh"
private_key = "${file("/root/id_rsa")}"
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"sudo apt update -y",
"sudo apt install nginx -y",
]

}
}
resource "digitalocean_firewall" "dagar" {
name = "only-22-and-80"
droplet_ids = ["${digitalocean_droplet.web.id}"]
inbound_rule {
protocol = "tcp"
port_range = "80"
source_addresses = ["0.0.0.0/0", "::/0"]
}
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = ["0.0.0.0/0", "::/0"]
}
}
resource "digitalocean_volume_attachment" "web1" {
droplet_id = "${digitalocean_droplet.web.id}"
volume_id = "${digitalocean_volume.web.id}"
}

我的验证和运行计划都成功了,但是当我运行时应用它给我错误:

Error: Error applying plan:

1 error(s) occurred:

* digitalocean_volume_attachment.web: 1 error(s) occurred:

* digitalocean_volume_attachment.web: Error attaching volume to droplet after retry timeout: [WARN] Error attaching volume (92f6052e-6d5f-11e9-8d4c-0a58ac14455b) to Droplet (142436110): POST https://api.digitalocean.com/v2/volumes/92f6052e-6d5f-11e9-8d4c-0a58ac14455b/actions: 404 (request "90720f03-3d3c-4003-97d5-c25e031845f0") volume not found

你能帮我看看是什么原因吗?

提前致谢。

最佳答案

以上问题已修复。我在不同区域创建了 Droplet 和卷,这就是为什么卷无法附加并且 API 给出 ​​404 未找到错误的原因。现在我已经进行了更改,一切正常。

谢谢。

关于terraform - 使用 terraform 在 digitalOcean 中使用 droplet 进行卷连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55964430/

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