我的 .tf文件中有resource "aws_instance" "webserver"
,其中包含provisioner "install-apache"
:
provider "aws" {
access_key = "ACCESS_KEY"
secret_key = "SECRET-KEY"
region = "us-east-1"
}
resource "aws_instance" "webserver" {
ami = "ami-b374d5a5"
instance_type = "t2.micro"
provisioner "install-apache" {
command = "apt-get install nginx"
}
}
运行terraform plan
后,我收到了错误消息:
* aws_instance.webserver: provisioner install-apache couldn't be found
根据terraform documentation,一切看起来都很好。
答案 0 :(得分:2)
provisioner值必须是以下值之一:
我相信你想要remote-exec
值
provider "aws" {
access_key = "ACCESS_KEY"
secret_key = "SECRET-KEY"
region = "us-east-1"
}
resource "aws_instance" "webserver" {
ami = "ami-b374d5a5"
instance_type = "t2.micro"
provisioner "remote-exec" {
inline = [
"apt-get install nginx"
]
}
}