3

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?

Kushan Gunasekera
  • 7,268
  • 6
  • 44
  • 58
stena
  • 667
  • 5
  • 19

1 Answers1

1

From terraspace version 2.1.6 you can now include -target flag with either:

  • terraspace plan; or
  • terraspace 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

Ari
  • 745
  • 1
  • 7
  • 23