0

I have resource "aws_instance" "webserver" in my .tf file which contains 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"
      }
    }

After running terraform plan I've got an error:

     * aws_instance.webserver: provisioner install-apache couldn't be found

According to the terraform documentation everything looks fine.

1 Answer 1

2

The provisioner value must be one of the following:

  • chef
  • file
  • local-exec
  • remote-exec

I believe in your case you want the remote-exec value

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
  • 1
    Well, it appears I've skipped the important part in the documentation. Thank you for pointing me to this part! :)
    – Anna
    Commented Jun 1, 2017 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.