Hi.
I will apologize for being a beginner with terraform.
My companies terraform files is split into multiple modules.
As we make changes we realize we usually need to run one perhaps 2 modules.
i want to keep my main.tf (this is highly simplified)
…
module “network” {
source = “./network”
}
module “appserver” {
source = “./appservers”
}
module “dbserver” {
source = “./dbservers”
}
the “–target” argument seems to require actual resource declaration.
I want to run everything in a specific module. is there some way to run a specific module???
Hi @pcooke2002,
If you expect to routinely apply only a subset of your resources then the typical answer is to split that into two different Terraform configurations, which you can then just use normal terraform apply
(with no special arguments).
The -target
option is intended for exceptional use in unusual cases, such as when working around temporary outages (if part of your infrastructure is not reachable). You can provide a module instance path to the -target
option, but I would not recommend doing that to meet the goal of routinely applying only a subset of your infrastructure.
There’s more information on how to use the -target
option, including what address syntax it expects, in the documentation section Resource Targeting.
1 Like