Complete the code to run a local command after resource creation.
resource "null_resource" "example" { provisioner "local-exec" { command = [1] } }
The local-exec provisioner runs the command locally. Here, echo Hello World prints a message after resource creation.
Complete the code to run a script file using local-exec provisioner.
resource "null_resource" "script_runner" { provisioner "local-exec" { command = [1] } }
The local-exec provisioner runs the command locally. To run a script, use bash deploy.sh to execute the shell script.
Fix the error in the local-exec provisioner command to print the current directory.
resource "null_resource" "pwd_example" { provisioner "local-exec" { command = [1] } }
The command must be a string. Without quotes, Terraform will error. So "pwd" is correct.
Fill both blanks to run a local command that lists files in the current directory.
resource "null_resource" "list_files" { provisioner "local-exec" { command = [1] [2] } }
pwd instead of lsThe command ls -l lists files with details. Both parts must be strings.
Fill all three blanks to run a local command that creates a directory named 'testdir' and lists its contents.
resource "null_resource" "create_and_list" { provisioner "local-exec" { command = [1] && [2] [3] } }
The command creates a directory mkdir testdir, then lists files with details ls -l. The && runs the second command only if the first succeeds.