garden icon indicating copy to clipboard operation
garden copied to clipboard

Runtime variables from Terraform modules are not available to Terraform plugin calls for other Terraform modules.

Open jamesmeneghello opened this issue 2 years ago • 3 comments

Bug

Current Behavior

Terraform module 1: shared-infrastructure, output: kms-key-id.

Terraform module 2: specific-service depends on shared-infrastructure, variable kms_key_id: ${runtime.services.shared-infrastructure.outputs.kms_key_id}.

This will fail during garden plugins terraform apply-module -- specific-service with no valid value for kms_key_id (${runtime.services.shared-infrastructure.outputs.kms_key_id} is the actual value saved in tfvars), presumably because when calling the module with the plugin, it doesn't have the context of the other previously-run module.

Expected behavior

I would expect the output of the previous module to be available to the next module.

Reproducible example

(see above, but if required I can put together a simple example)

Workaround

The only workaround I can determine is to ensure that all required resources are within a single Terraform module, but this becomes pretty messy quickly.

Suggested solution(s)

Maybe determine outputs from dependent TF modules during the plugin run?

Additional context

Your environment

  • OS: Ubuntu 20.04 LTS
  • How I'm running Kubernetes: Kind

garden version: 0.12.40

jamesmeneghello avatar May 23 '22 12:05 jamesmeneghello

Thanks for pointing this out!

To speed up our debugging and fixing this issue, could you maybe provide us with a simple example project where this problem occurs?

thsig avatar May 24 '22 09:05 thsig

Sure, I'll try to find time to put one together.

jamesmeneghello avatar May 25 '22 00:05 jamesmeneghello

This issue has been automatically marked as stale because it hasn't had any activity in 90 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Garden a better product!

stale[bot] avatar Sep 21 '22 03:09 stale[bot]

This issue has been automatically marked as stale because it hasn't had any activity in 90 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Garden a better product!

stale[bot] avatar Jan 07 '23 20:01 stale[bot]

This issue has been automatically marked as stale because it hasn't had any activity in 90 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Garden a better product!

stale[bot] avatar May 21 '23 21:05 stale[bot]

This was fixed in 0.13. Please let us know if it's still an issue.

vvagaytsev avatar Jul 06 '23 12:07 vvagaytsev