Complete the code to run a remote command on the instance using the remote-exec provisioner.
provisioner "remote-exec" { inline = ["[1]"] }
The inline block runs commands on the remote instance. Here, echo Hello, World! is a simple command to run.
Complete the code to specify the connection type for the remote-exec provisioner.
connection {
type = "[1]"
user = "ubuntu"
private_key = file("~/.ssh/id_rsa")
host = self.public_ip
}The connection block defines how Terraform connects to the instance. For Linux instances, ssh is used.
Fix the error in the provisioner block to correctly run multiple commands remotely.
provisioner "remote-exec" { inline = ["sudo apt-get update", [1]] }
Commands in the inline list must be strings inside quotes. Option A correctly quotes the command.
Fill both blanks to define a remote-exec provisioner that runs a command and uses SSH connection with a specific user.
connection {
type = "[1]"
user = "[2]"
private_key = file("~/.ssh/id_rsa")
host = self.public_ip
}
provisioner "remote-exec" {
inline = ["sudo systemctl restart nginx"]
}The connection type for Linux instances is ssh, and the default user for Ubuntu instances is ubuntu.
Fill all three blanks to create a remote-exec provisioner that runs a command, uses SSH connection, and specifies the host.
connection {
type = "[1]"
user = "[2]"
private_key = file("~/.ssh/id_rsa")
host = [3]
}
provisioner "remote-exec" {
inline = ["sudo apt-get install -y nginx"]
}Use ssh as connection type, ubuntu as user, and self.public_ip to specify the instance's public IP address.