Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Using this setup
me@mybox:~terraform -v
Terraform v0.12.8
+ provider.digitalocean v1.7.0
I try to create two droplets serving Nginx using this Terraform file
resource "digitalocean_droplet" "web" {
count = 2
name = "web-${count.index}"
image = "ubuntu-14-04-x64"
region = "fra1"
size = "512mb"
private_networking = true
ssh_keys = [
"${var.ssh_fingerprint}"
]
connection {
user = "root"
type = "ssh"
host = digitalocean_droplet.web[count.index].ipv4_address
private_key = "${file(var.pvt_key)}"
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
# install nginx
"sudo apt-get update",
"sudo apt-get -y install nginx",
"curl -sSL https://repos.insights.digitalocean.com/install.sh | sudo bash"
]
}
}
but get this error when running terraform plan
Error: Cycle: digitalocean_droplet.web[1], digitalocean_droplet.web[0]
If I change the specification of connection.host to foo terraform runs without errors. Of course, it becomes hard to run any commands on the host afterwards, so my question is this:
How do I specify the host address when using count variables?
Thanks in advance and have a nice day, Morten
72e571841e7f4a6881090a2f3e93c0
dom77a6e2e9d3a2
Christoffer Braathen
Jaimin Joshi
099d155dd62c45078c85bd5b98d003
82488cefb7d74db1ad87250ea4f452
Mrugesh Mohapatra
828c1c19bec3419eb032d05c128960
Rumyana Rumenova
Ben Roberts
garry55441234