Terraform provisioners can be added to any resource block.
Terraform provisioners can be added to any resource block.
Terraform provisioners cannot be added to any resource block. They are typically added to resource blocks that support them. The use of provisioners complicates the Terraform model and is not recommended where other solutions are available. It is crucial to use provisioners only as a last resort for actions that cannot be performed through other Terraform means.
A is correct https://www.terraform.io/language/resources/provisioners/syntax resource "aws_instance" "web" { # ... provisioner "local-exec" { command = "echo The server's IP address is ${self.private_ip}" } }
the key of this question is "could you use a local-exec provisioner in any type of resource?", yes, because the execution of this provisioner is on my local so we couldnuse local-exec in any resource type because it is independent of the type of resource. Answer is A "true"
Please stop confusing people. Basics of Provisioner block : always bind with resource block
I can add local-exec to any resource block such as aws_s3, aws_eip and etc., So, answer is A
Since the local-exec provisioner executes on the machine running Terraform and not on the resource itself, it can indeed be added to any resource block. The actions taken by the local-exec provisioner are not dependent on the type of resource, so it's possible to use this provisioner with any resource in Terraform.
Provisioners can only be added to virtual machines and other compute resources
Yeah, looks like B "Provisioners can be used to model specific actions on the local machine or on a remote machine in order to prepare servers or other infrastructure objects for service"
This statement is wrong. Local exec provisioners can be added to resource blocks that are not virtual machines or compute instances
Provisioner is an arbitrary command executed by the terraform when a resource is created/destroyed. It is not related to a resource itself. The creation/destruction of a resource is just a trigger.
Provisioners can be added to any resource block in Terraform configuration, but it is not recommended to use them for configuration management as it goes against the declarative approach of Terraform. Provisioners should only be used as a last resort when no other Terraform resource types are available to handle a specific task.
Yes, Terraform provisioners can be added to any resource block. Provisioners are used to execute scripts or commands on a resource after it has been created or updated.
The new exam doesn't ask about provisioners anymore
answer should be "B" Can you add a provisioner to below resource block ? ============================== resource "azurerm_network_interface" "Nic-1" ==============================
resource "azurerm_network_interface" "Nic-1" { # ... provisioner "local-exec" { command = "echo 'Network interface created'" } }
Can you not add "local-exec" provisioner to any resource block? I pick A
Its a B. You can't add a provisioned to the Terraform block in example.
They ask about resource blocks. Terraform block is not a resource block.
You are right, but, within all "resource" blocks, not all of them can address a provisioner, for example, an aws_eip
You are right, but, within all "resource" blocks, not all of them can address a provisioner, for example, an aws_eip
how we can execute scripts for example in such resource "aws_security_group" even its resource? Provisioners are used to execute scripts on a local or remote machine as part of resource creation or destruction. so answer is False.
This statement is incorrect. Local exec provisioners can execute in any resource block. I think you are referrring to remote-exec provisioners which need to be in resource block of compute instances
B is correct answer. False. https://www.terraform.io/language/providers/requirements#requiring-providers
B is certainly false: The question is about provisioners not providers.
If you are certain that provisioners are the best way to solve your problem after considering the advice in the sections above, you can add a provisioner block inside the resource block of a compute instance. B is correct
A: I can add a local-exec to any resource block
True. Terraform provisioners can be added to any resource block in a Terraform configuration file. Provisioners allow you to perform additional configuration tasks on a resource after it has been created. For example, you might use a provisioner to install software on an EC2 instance or run a script on a newly created VM. To add a provisioner to a resource block, you can use the provisioner block within the resource block. You can add multiple provisioners to a single resource block if necessary. Here is an example of adding a provisioner to an EC2 instance resource: Copy code resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" provisioner "remote-exec" { inline = [ "sudo apt-get update", "sudo apt-get install -y nginx", ] } } In this example, the provisioner will run the apt-get update and apt-get install commands on the EC2 instance after it has been created. So, option A, true, is the correct answer. Option B, false, is incorrect.
If you are certain that provisioners are the best way to solve your problem after considering the advice in the sections above, you can add a provisioner block inside the resource block of a compute instance.
The answer is A
AAAAAAAA
The answer is False. Terraform provisioners can only be added to resource blocks that support them
A. True Terraform provisioners can be added to any resource block. Provisioners are used to execute scripts or commands on a local or remote machine as part of resource creation or destruction. They are defined within a resource block and allow you to perform actions such as initializing, configuring, or setting up resources after they have been created.
Answer is false (B)
If you are certain that provisioners are the best way to solve your problem after considering the advice in the sections above, you can add a provisioner block inside the resource block of a compute instance. above from the doc B is correct
Literally just tried it in an S3 resource. lol almost like they put out a false question list to weed people out. Error: Unsupported block type on main.tf line 20, in module "s3_bucket": 20: provisioner "local-exec" { Blocks of type "provisioner" are not expected here.
Never mind, forgot that I was using a module. Seemed to validate and plan ok with an S3 resource while also having a provisioner. Has to be a trick question. The documentation states "you can add a provisioner block inside the resource block of a compute instance." They call out compute instance, but it appears to work on non-compute resource blocks. ¯\_(ツ)_/¯ I'm calling it true from my testing. However, the apply did fail due to what was in the provisioner. https://www.terraform.io/language/resources/provisioners/syntax#how-to-use-provisioners
A is right: You definitively CAN add the "local-exec" provisioner to any resource, as this executes the command on the local system where the tf runs. See the doc example with the "null_resource" for local-exec. Please note that people maybe voted B because "remote-exec" is the only provisioner they know. https://www.terraform.io/language/resources/provisioners/local-exec
A https://www.phillipsj.net/posts/introduction-to-terraform-provisioners/ As you continue learning about Terraform, you will start hearing about provisioners. Terraform provisioners can be created on any resource and provide a way to execute actions on local or remote machines.
I think ans is A
A is correct
A is correct
A is correct
definitely A
It should be A. 90%. The only problem is the word "can" because the provisioner MUST or always be inside the resource block... that disturbs a bit but I still say A.
Option A is common sense
A is correct
The answer is False. Terraform provisioners can only be added to resource blocks that support them. For example, the AWS provider supports the remote-exec provisioner, but the Azure provider does not.
But what about the local-exec ?
The correct answer is B. False. Terraform provisioners are not added to resource blocks directly. Instead, provisioners are added as separate blocks within a resource block. Provisioners are used to execute scripts or commands on a resource after it has been created or updated. They are defined outside of the resource block and are associated with the resource using the "provisioner" keyword followed by the specific provisioner type CHATGPT
The correct answer is: B. False Explanation: Terraform provisioners are not automatically supported in all resource blocks. They are designed to be used with specific types of resources, primarily those that involve remote execution or configuration (such as virtual machines or instances). However, not every resource type is compatible with provisioners.