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"
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 should be "B"
Can you add a provisioner to below resource block ?
==============================
resource "azurerm_network_interface" "Nic-1"
==============================
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.
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 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.
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.
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.
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.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
GopinathM
Highly Voted 2 years, 2 months agoagmesas
Highly Voted 1 year, 9 months agosamimshaikh
Most Recent 11 months agoPradh
1 year, 1 month agoilmi70
9 months agodebabrata6983
1 year, 2 months agoBere
1 year, 3 months agomodarov
1 year, 3 months agoLunarPhobia
1 year, 4 months agoHa_Baruh_Architect13
1 year, 4 months agoJlee7
1 year, 5 months agojoyboy23
1 year, 4 months agoNi33
1 year, 6 months agoBluemoon22
1 year, 7 months agosylvergorilla
1 year, 7 months agoPower123
1 year, 7 months agoNunyabiznes
1 year, 8 months agoTanacet
1 year, 9 months agoFarziWaliMarzi
1 year, 11 months ago