У меня есть ресурс "aws_instance", который включает в себя файл "Provider".Это все работает, как и ожидалось, когда экземпляр EC2 вначале отсутствует.
Как я могу повторно запустить поставщик, если файл удален с виртуальной машины?
resource "aws_instance" "example" {
ami = "ami-0b0a60c0a2bd40612"
instance_type = "t2.micro"
key_name = "secret"
security_groups = ["terraform-basic-ssh-http"]
provisioner "file" {
source = "install-nginx.sh"
destination = "/tmp/install-nginx.sh"
connection {
type = "ssh"
user = "ubuntu"
private_key = "${file("/local/path/to/my/key.pem")}"
}
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/install-nginx.sh",
"/tmp/install-nginx.sh"
]
connection {
type = "ssh"
user = "ubuntu"
private_key = "${file("/local/path/to/mykey.pem")}"
}
}
}