millions-pharmacist-626
09/18/2023, 2:59 PMstaging
and prod
, and there is one resource that needs to be global (let's say an S3 bucket, for simplicity). Can this bucket "exists" in both stacks, without being created twice, assuming that it's resource_name
and configurations are exactly the same between them ?dry-keyboard-94795
09/18/2023, 3:03 PMimport
it (docs)
but be mindful that either stack can delete it.
You could also use the .get()
method for one of the stacks. In your case, prod
creates it, and staging
would use .get
millions-pharmacist-626
09/18/2023, 3:04 PMdry-keyboard-94795
09/18/2023, 3:05 PMlittle-library-54601
09/18/2023, 3:05 PMmillions-pharmacist-626
09/18/2023, 3:06 PMcurrent_stack = pulumi.get_stack()
if current_stack == 'staging':
resource = aws.Resource(...)
else:
resource = aws.Resource().get()
correct ?dry-keyboard-94795
09/18/2023, 3:07 PMmillions-pharmacist-626
09/18/2023, 3:07 PMlittle-library-54601
09/18/2023, 3:10 PMvar stagingStackReference = new StackReference("staging");
var communicationsServicesConnectionStringOutput = stagingStackReference.GetOutput("CommunicationsServicesConnectionString");
var signalRConnectionStringOutput = stagingStackReference.GetOutput("SignalRConnectionString");
I don't need the import, I believe, because I'm explicitly outputting the values I need for "production" when the "staging" stack runs.millions-pharmacist-626
09/18/2023, 3:11 PMbillowy-army-68599
millions-pharmacist-626
09/18/2023, 5:06 PMbillowy-army-68599
millions-pharmacist-626
09/18/2023, 5:12 PMyou have one AWS account?yep, only one
I’d generally make this its own Pulumi project in this situation and have a single stack in thereyeah sometimes I do this, in this specific case I couldn't be assed to do so and was wondering if there was a specific alternative. The stack check that has been suggested above is good enough tbh