Is there a way to share resource between stacks wi...
# general
a
Is there a way to share resource between stacks without StackReference? I have only one resource in entire project (aws.iam.User whose credentials are used by 3rd party and it should be same for all environments) and it seems a bit overhead to create separate pulumi project and stack just to be able to get stackreference for that user in my dev/qa/prod stacks
b
if you know the name then you can use .get to look up the User?
a
so if user is not found and created by dev stack initially, qa and prod stacks will be able to get it ?
I still want to create the user from my stack
I came up with following solutions eventually: 1. created new "shared" stack in addition to dev/qa/prod 2. Added shared resource to that stack like:
Copy code
const userName = "sharedUser";
if (pulumi.getStack() == "shared") {
        const user = new aws.iam.User(userName, { name: userName });
        return;
    }

const user = aws.iam.User.get(userName, userName);
username doesn't have to be globally unique, so I just know it statically (will take from stack config), then I don't need stack reference to grab it from output of shared stack - just do .get() like you suggested assuming that shared stack was created