我正在尝试使用digitalocean提供程序中的terraform附加带有液滴的体积。我能够创建液滴和体积。但是,当我尝试用液滴附加体积时,我得到了错误。
下面是我的代码:
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
您能帮我找出原因吗?
谢谢。
答案 0 :(得分:0)
上述问题已解决。我在不同区域创建了液滴和体积,这就是为什么体积无法附加的原因,并且API给出了404 not found错误。现在我进行了更改,一切正常。
谢谢。