resource "digitalocean_droplet" "web-server" {
image = "ubuntu-18-04-x64"
name = "web-server"
region = "nyc2"
size = "s-1vcpu-1gb"
ssh_keys = [
var.ssh_fingerprint
]
connection {
host = digitalocean_droplet.web-server.ipv4_address
user = "root"
type = "ssh"
private_key = file(var.pvt_key)
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"sudo apt-get update",
"sudo apt-get -y install nginx"
]
}
}
目前,我正在使用上述方法通过Terraform在 Digital Ocean 液滴上安装 NGINX ,但是还有另一种方法可以让 Terraform 管理这个状态吗?我希望能够管理升级、负载平衡等事情,这似乎是一种反模式?