suvhotta
suvhotta

Reputation: 96

How to share outputs across stacks in cdktf?

I'm using cdktf 0.15.5 and aws provider. I've created an IAM role in one stack and I wish to use in another stack while creating an EC2 instance.

As of now in cdktf(python) using the outputs of one stack in another stack by creating instance variables of one stack and passing the same during the initialisation of the second/dependent stack, as mentioned in the official docs: (https://developer.hashicorp.com/terraform/cdktf/concepts/stacks#cross-stack-reference

So wanted to check if there is any better way to send data cross stack apart from the above method.

Something mentioned vaguely in the official docs that the output variables could also be used to transfer data cross stacks. https://developer.hashicorp.com/terraform/cdktf/concepts/variables-and-outputs#when-to-use-output-values

Upvotes: 1

Views: 1323

Answers (1)

Technowise
Technowise

Reputation: 1357

I have previously used remote state data source for this purpose, which worked well for me. But I can't say if this is best since I have not used any other method.

Upvotes: 0

Related Questions