Terraspace: Call terraform with -target option

Viewed 498

We use terraspace to manage our infrastructure. Because of dependend resources, we need to call terraform apply twice, once with an option target, once without.

What we are currently doing:

terraspace up somestack

Then we get an error:

The "for_each" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the for_each depends on.

Then we change to .terraspace-cache/location/env/stacks/somestack and call

terraform apply -target module.someservice

After that

terraform apply

The question is: can this be automated, that we are done with just terraspace up somestack and would this be a good idea?

0 Answers
Related