0
0
Terraformcloud~10 mins

File 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 specify the source file for the file provisioner.

Terraform
provisioner "file" {
  source = [1]
  destination = "/tmp/example.txt"
}
Drag options to blanks, or click blank then click option'
A"./localfile.txt"
B"remote_file.txt"
C"/tmp/example.txt"
D"/remote/path/file.txt"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a remote path as source instead of a local path.
Confusing source and destination paths.
2fill in blank
medium

Complete the code to specify the destination path for the file provisioner.

Terraform
provisioner "file" {
  source      = "./config.json"
  destination = [1]
}
Drag options to blanks, or click blank then click option'
A"./config.json"
B"config.json"
C"/etc/config.json"
D"/tmp/config.json"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a local path as destination.
Omitting the leading slash for absolute path.
3fill in blank
hard

Fix the error in the file provisioner block by completing the missing attribute.

Terraform
provisioner "file" {
  source = "./app.conf"
  [1] = "/etc/app.conf"
}
Drag options to blanks, or click blank then click option'
Adestination
Bpath
Ctarget
Dlocation
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attribute names like 'path' or 'target'.
Misspelling 'destination'.
4fill in blank
hard

Fill both blanks to complete the file provisioner block that uploads a script and sets its permissions.

Terraform
provisioner "file" {
  source      = [1]
  destination = [2]
}

provisioner "remote-exec" {
  inline = ["chmod +x [2]"]
}
Drag options to blanks, or click blank then click option'
A"./deploy.sh"
B"/tmp/deploy.sh"
C"/usr/local/bin/deploy.sh"
D"./script.sh"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up source and destination paths.
Using relative paths for destination.
5fill in blank
hard

Fill all three blanks to create a file provisioner that uploads a config file, sets permissions, and runs a command remotely.

Terraform
provisioner "file" {
  source      = [1]
  destination = [2]
}

provisioner "remote-exec" {
  inline = ["chmod [3] [2]", "systemctl restart myservice"]
}
Drag options to blanks, or click blank then click option'
A"./config.yaml"
B"/etc/myapp/config.yaml"
C"+x"
D"-R"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect chmod flags.
Confusing source and destination paths.