gray-knife-50817
09/19/2023, 3:19 PMOutput
from project A/stack A
in project B/stack B
, project C/stack C
in multiple files as inputs to resources (keeping things DRY)
Current Setup:
• Function declared in A
which uses StackReference
to get an Output
from A
(seems odd to use StackReference
for the current stack but is there a better way?)
• Files in B
and C
import the function from A
and save the Output
to a variable
• The variable gets passed as input for creating resources in B
and C
• The CI pipeline runs a preview
on all stacks (A
, B
, C
etc) and fails on B
because it doesn't recognise the variable which is dependent on the Output
from A
, since A
hasn't had an up
yet to actually produce the Output
Am I missing something here in terms of the dependency? Happy to provide more context if helpful.
Thanks in advance ✌️billowy-army-68599
gray-knife-50817
09/19/2023, 3:23 PMbillowy-army-68599
gray-knife-50817
09/19/2023, 3:29 PMStackReference
in multiple places to get the same Output
so my logic was to create a function in the module where it came from, to be reused in multiple places elsewherebillowy-army-68599
class VpcStackInfo(pulumi.StackReference):
vpc_id = pulumi.Output[Any]
private_subnet_ids = pulumi.Output[Any]
public_subnet_ids = pulumi.Output[Any]
cidr_block = pulumi.Output[Any]
def __init__(self, stack_name: str):
super().__init__(f"ignistech/vpc/{stack_name}")
self.vpc_id = self.require_output("vpc_id") # type: ignore
self.private_subnet_ids = self.require_output("private_subnet_ids") # type: ignore
self.public_subnet_ids = self.require_output("public_subnet_ids") # type: ignore
self.cidr_block = self.require_output("cidr_block") # type: ignore
Then reference it like this:
vpc = stackinfo.VpcStackInfo(STACK)
gray-knife-50817
09/19/2023, 4:00 PMpreview
is still failing for B
because A
hasn't been up
'd yet I think. But all the changes are going together in the pipeline. Is there something I'm missing for dependency on A
by B
that needs to be declared for the preview
to work?