This message was deleted.
# general
s
This message was deleted.
g
Mm actually I realized I can probably just import the prod ecr repo into my staging stack. But is it appropriate for a resource to be managed by two different stacks?
b
you can't manage a resource by two different stacks, no. What most people do here is set a config boolean:
Copy code
pulumi config set enableECR
Then use an if statement if it's enabled
g
@billowy-army-68599 Thanks for the reply! I was able to import the same resource into both stacks, so I think that I can manage the same resource in both stacks, but perhaps I shouldn’t. I know that I can toggle the ECR on in one environment and off in another. The issue I’m running into is that I need to reference the ECR resource in both stacks, since my AWS tasks need to reference images in that one ECR instance.
An alternative path would be to output the ECR id from the production stack and import it into my staging stack. Is that possible, and would that be a better approach?
b
you definitely shouldn't manage the resource in both stacks
you have two options really: - move the ECR definition into its own project and use a stack reference - use the if statement method I defined above, and if it's set to false use a
.get()
method
so:
Copy code
if true {
 // create the resource
} else {
  ecr.get_repository
}
g
Thank you, that solved my issue. New to Pulumi and hadn’t made use of the get functions yet