Terraform:无法找到供应商

时间:2017-06-01 08:18:45

标签: amazon-web-services amazon-ec2 provisioning terraform

我的 .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,一切看起来都很好。

1 个答案:

答案 0 :(得分:2)

provisioner值必须是以下值之一:

  • 厨师
  • 文件
  • 本地-EXEC
  • 远程EXEC

我相信你想要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"
    ]
  }
}