Challenge - 5 Problems
Remote-exec Provisioner Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
What is the output of this Terraform remote-exec provisioner block?
Given the following Terraform resource configuration, what will be the output when the remote-exec provisioner runs successfully?
Terraform
resource "aws_instance" "example" { ami = "ami-12345678" instance_type = "t2.micro" provisioner "remote-exec" { inline = [ "echo Hello World > /tmp/hello.txt", "cat /tmp/hello.txt" ] connection { type = "ssh" user = "ec2-user" private_key = file("~/.ssh/id_rsa") host = self.public_ip } } }
Attempts:
2 left
💡 Hint
Think about what the inline commands do and how remote-exec outputs command results.
✗ Incorrect
The inline commands first create a file with 'Hello World' and then output its contents. The remote-exec provisioner logs the output of commands, so 'Hello World' appears in the logs.
❓ Configuration
intermediate2:00remaining
Which option correctly configures a remote-exec provisioner with a WinRM connection?
You want to run a remote-exec provisioner on a Windows instance using WinRM. Which configuration snippet is correct?
Attempts:
2 left
💡 Hint
WinRM uses username and password, not SSH keys, and can use HTTP or HTTPS.
✗ Incorrect
Option D correctly sets type to winrm, uses user and password, sets host to public IP, and disables HTTPS which is common for testing.
❓ Architecture
advanced2:00remaining
What is the main risk of using remote-exec provisioner in Terraform for production infrastructure?
Consider a production environment where Terraform uses remote-exec provisioners to configure instances after creation. What is the biggest architectural risk of this approach?
Attempts:
2 left
💡 Hint
Think about how Terraform tracks resources and what happens when changes happen outside Terraform.
✗ Incorrect
Remote-exec runs commands on instances but Terraform does not track the changes made by those commands, leading to possible drift between actual and declared state.
❓ security
advanced2:00remaining
Which option describes a security best practice when using remote-exec provisioners?
When using remote-exec provisioners in Terraform, which practice improves security?
Attempts:
2 left
💡 Hint
Think about minimizing exposure of credentials and limiting access.
✗ Incorrect
Using ephemeral SSH keys that exist only during provisioning reduces risk if keys are compromised. Avoid storing private keys in code or using root unnecessarily.
🧠 Conceptual
expert2:00remaining
What happens if a remote-exec provisioner command fails during Terraform apply?
During a Terraform apply, a remote-exec provisioner runs a command that returns a non-zero exit code. What is Terraform's behavior?
Attempts:
2 left
💡 Hint
Consider how Terraform treats provisioner failures during resource creation.
✗ Incorrect
Terraform treats provisioner failures as resource creation failures, stops the apply, and attempts to rollback or destroy the resource to keep state consistent.