0
0
Terraformcloud~10 mins

Provisioner failure behavior 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 provisioner that runs a script on the resource.

Terraform
resource "null_resource" "example" {
  provisioner "[1]" {
    script = "setup.sh"
  }
}
Drag options to blanks, or click blank then click option'
Afile
Blocal-exec
Cnull
Dremote-exec
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'remote-exec' when the script should run locally.
Using 'file' provisioner instead of executing a script.
2fill in blank
medium

Complete the code to make Terraform continue even if the provisioner fails.

Terraform
resource "null_resource" "example" {
  provisioner "local-exec" {
    command = "exit 1"
    [1] = true
  }
}
Drag options to blanks, or click blank then click option'
Aignore_errors
Bcontinue_on_error
Cfail_on_error
Dallow_failure
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fail_on_error' which causes Terraform to stop on failure.
Using non-existent arguments like 'continue_on_error'.
3fill in blank
hard

Fix the error in the provisioner block to correctly handle failure behavior.

Terraform
resource "null_resource" "example" {
  provisioner "local-exec" {
    command = "exit 1"
    ignore_errors = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"true"
B1
Cyes
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around true, which makes it a string.
Using numbers or words like 'yes' instead of boolean.
4fill in blank
hard

Fill both blanks to configure a remote-exec provisioner that retries on failure.

Terraform
resource "null_resource" "example" {
  provisioner "remote-exec" {
    inline = ["echo Hello"]
    [1] = 3
    [2] = 10
  }
}
Drag options to blanks, or click blank then click option'
Amax_retries
Bretry_delay_sec
Cretry_delay
Dmax_attempts
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max_attempts' which is not a valid argument.
Using 'retry_delay' without '_sec' suffix.
5fill in blank
hard

Fill all three blanks to define a provisioner that uploads a file and ignores failure.

Terraform
resource "null_resource" "example" {
  provisioner "file" {
    source      = "app.zip"
    destination = "/tmp/app.zip"
    [1] = "ubuntu"
    [2] = "/home/ubuntu/.ssh/id_rsa"
    [3] = true
  }
}
Drag options to blanks, or click blank then click option'
Auser
Bprivate_key
Cignore_errors
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' instead of 'user' which is the correct argument.
Not setting 'ignore_errors' to true to allow continuation on failure.