0
0
Terraformcloud~10 mins

Remote-exec provisioner in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run a remote command on the instance using the remote-exec provisioner.

Terraform
provisioner "remote-exec" {
  inline = ["[1]"]
}
Drag options to blanks, or click blank then click option'
Aaws s3 ls
Bterraform apply
Cping google.com
Decho Hello, World!
Attempts:
3 left
💡 Hint
Common Mistakes
Using local commands like 'terraform apply' which run on your machine, not remotely.
Forgetting to put the command inside quotes.
2fill in blank
medium

Complete the code to specify the connection type for the remote-exec provisioner.

Terraform
connection {
  type     = "[1]"
  user     = "ubuntu"
  private_key = file("~/.ssh/id_rsa")
  host     = self.public_ip
}
Drag options to blanks, or click blank then click option'
Awinrm
Bssh
Chttps
Dhttp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'winrm' for Linux instances.
Using HTTP or HTTPS which are not connection types for remote-exec.
3fill in blank
hard

Fix the error in the provisioner block to correctly run multiple commands remotely.

Terraform
provisioner "remote-exec" {
  inline = ["sudo apt-get update", [1]]
}
Drag options to blanks, or click blank then click option'
A"sudo apt-get upgrade -y"
Bsudo apt-get upgrade -y
C"sudo apt-get install nginx"
Dsudo apt-get install nginx
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting commands inside the inline list.
Mixing quoted and unquoted commands.
4fill in blank
hard

Fill both blanks to define a remote-exec provisioner that runs a command and uses SSH connection with a specific user.

Terraform
connection {
  type     = "[1]"
  user     = "[2]"
  private_key = file("~/.ssh/id_rsa")
  host     = self.public_ip
}

provisioner "remote-exec" {
  inline = ["sudo systemctl restart nginx"]
}
Drag options to blanks, or click blank then click option'
Assh
Badmin
Cubuntu
Dwinrm
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'winrm' connection type for Linux instances.
Using 'admin' as user instead of 'ubuntu'.
5fill in blank
hard

Fill all three blanks to create a remote-exec provisioner that runs a command, uses SSH connection, and specifies the host.

Terraform
connection {
  type        = "[1]"
  user        = "[2]"
  private_key = file("~/.ssh/id_rsa")
  host        = [3]
}

provisioner "remote-exec" {
  inline = ["sudo apt-get install -y nginx"]
}
Drag options to blanks, or click blank then click option'
Awinrm
Bubuntu
Cself.public_ip
Dssh
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'winrm' for Linux instances.
Not referencing the host correctly.
Using wrong user names.