Recall & Review
beginner
What is the purpose of a connection block in Terraform when using SSH?
A connection block tells Terraform how to connect to a remote machine using SSH. It provides details like the host address, user name, and authentication method so Terraform can run commands or copy files on that machine.
Click to reveal answer
beginner
Which key fields are commonly used inside a Terraform SSH connection block?
Common fields include
host (IP or hostname), user (username to log in), private_key (SSH private key content), and port (SSH port, usually 22).Click to reveal answer
intermediate
How do you specify the SSH private key in a Terraform connection block?
You use the
private_key field and provide the private key as a string. For example, you can read it from a file using Terraform's file() function.Click to reveal answer
beginner
True or False: The connection block is required for Terraform to manage resources on remote machines via SSH.
True. Without a connection block, Terraform does not know how to connect to the remote machine to execute commands or transfer files.
Click to reveal answer
beginner
What happens if you omit the
port field in a Terraform SSH connection block?Terraform will use the default SSH port 22 to connect to the remote machine.
Click to reveal answer
Which field in a Terraform connection block specifies the username for SSH?
✗ Incorrect
The
user field specifies the username Terraform uses to log in via SSH.What is the default SSH port used if the
port field is not set in the connection block?✗ Incorrect
SSH uses port 22 by default.
How can you provide the SSH private key content in a Terraform connection block?
✗ Incorrect
The
private_key field holds the SSH private key content as a string.Which Terraform resource block commonly uses a connection block for SSH?
✗ Incorrect
The
null_resource often uses connection blocks to run remote commands via SSH.What is the main reason to use a connection block in Terraform?
✗ Incorrect
Connection blocks tell Terraform how to connect to remote machines to run commands or copy files.
Explain how a Terraform connection block is used to connect to a remote machine via SSH.
Think about what information Terraform needs to log in and run commands remotely.
You got /5 concepts.
Describe what happens if you omit the port field in a Terraform SSH connection block.
Consider the standard SSH port and how Terraform behaves without explicit port info.
You got /3 concepts.