Reputation: 785
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?
Upvotes: 3
Views: 1068
Reputation: 865
From terraspace
version 2.1.6 you can now include -target
flag with either:
terraspace plan
; orterraspace up
As according to this merged PR: https://github.com/boltops-tools/terraspace/pull/258
before the PR: the "target" argument was not passed down to terraform
after the PR: it is passed (speeds things up)
Example given:
You can test with
terraspace up -target=a.given.resource
Upvotes: 1