2017-06-01 89 views
0

我在其中包含我.tf文件resource "aws_instance" "webserver"provisioner "install-apache"Terraform:供應方找不到

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一切看起來不錯。

回答

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" 
    ] 
    } 
} 
+1

好吧,看來我跳過了文檔中的重要部分。謝謝你指點我這個部分! :) –