首页 文章

Terraform:无法找到供应商

提问于
浏览
0

我的 .tf file 中有 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 回答

  • 2

    provisioner值必须是以下值之一:

    • 厨师

    • 文件

    • local-exec

    • remote-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"
        ]
      }
    }
    

相关问题