You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script.
Which of the following commands would you use first?
You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script.
Which of the following commands would you use first?
To rerun the script in a local-exec provisioner within a null resource in Terraform, you should use the command 'terraform taint null_resource.run_script'. This command marks the specified resource as tainted, which forces Terraform to consider it as requiring replacement during the next apply phase. When you subsequently run 'terraform apply', Terraform will recreate the null resource and rerun the provisioner script. While 'terraform taint' is deprecated in favor of 'terraform apply -replace', 'terraform taint' remains the correct choice among the given options for rerunning the script.
Which provisioner invokes a process on the resource created by Terraform?
The remote-exec provisioner invokes a script or command on a remote resource after it has been created. This provisioner connects to the remote resource using SSH or WinRM and runs the specified commands directly on that resource. This is different from the local-exec provisioner, which runs commands on the machine where Terraform is being executed, not on the remote resource. Therefore, for invoking a process on a resource created by Terraform, the remote-exec provisioner is the appropriate choice.
Which of the following is not true of Terraform providers?
All the given statements about Terraform providers are true. Providers can indeed be written by individuals, maintained by a community of users, and some are maintained by HashiCorp. Additionally, both major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers. Therefore, the correct answer is 'None of the above'.
What command does Terraform require the first time you run it within a configuration directory?
The 'terraform init' command is used to initialize a working directory containing Terraform configuration files. This step is required before any other Terraform commands can be run in a new configuration directory, as it prepares the directory by installing required modules and providers.
You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code.
What is the best method to quickly find the IP address of the resource you deployed?
Given that no outputs were created in your Terraform code, running 'terraform output ip_address' will not yield any information. The best method to quickly find the IP address of the deployed resource is to run 'terraform state list' to find the name of the resource and then use 'terraform state show' followed by the resource name to display its attributes, which include the public IP address.