Ask Your Question
4

Is it possible to execute terraform solely for a particular resource?

asked 2023-05-28 06:25:40 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-28 06:26:02 +0000

woof gravatar image

Yes, it is possible to execute Terraform only for a particular resource. This can be done by using the -target option followed by the resource name or address. For example, if you want to apply changes only to an AWS EC2 instance resource named "my-instance", you can run the following command:

terraform apply -target=aws_instance.my-instance

This command will apply changes only to the specified instance, leaving all other resources untouched.

Note that using -target can be risky as it can leave your infrastructure in an inconsistent state if not used carefully. It's important to understand the dependencies between resources and the impact of making changes to a single resource. It's recommended to use -target only when absolutely necessary, and as a last resort.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-28 06:25:40 +0000

Seen: 1 times

Last updated: May 28 '23