Wednesday, August 2, 2023

remote-exec Provisioner in terraform

 ##### remote-exec Provisioner demo


resource "aws_instance" "dev-instance" {


  ami           = "ami-05548f9cecf47b442"

  instance_type = "t2.micro"

  key_name = "pgsql_key"

  


  connection {

    type = "ssh"

    user = "ec2-user"

    private_key = file("./pgsql_key.pem")

    host = self.public_ip


  }


  provisioner "remote-exec" {


    inline = [ 

        "sudo yum install -y mysql*"

     ]

    

  }


}



Note: we can use existing key or generate new key 

No comments:

Post a Comment