We may have made a mistake in our output exports.....
# general
e
We may have made a mistake in our output exports.. we went with object exports to make things more organized like this:
Copy code
export const userPoolExports = {
  id: userPool.id,
  arn: userPool.arn,
  urn: userPool.urn,
  groups: {
    customers: {
      id: customersGroup.id,
      urn: customersGroup.urn,
      name: customersGroup.name,
    },
    employees: {
      id: employeesGroup.id,
      urn: employeesGroup.urn,
      name: employeesGroup.name,
    },
  },
  clients: {
    web: {
      id: userPoolWebClient.id,
      urn: userPoolWebClient.urn,
      name: userPoolWebClient.name,
    },
  },
};
However, it doesn't seem like we can do this:
Copy code
const bootstrapStackRef = new pulumi.StackReference(
  `us/bootstrap/production`
);

const userPoolId = bootstrapStackRef.getOutput('userPoolExports.id');
This results in
userPoolId
being
undefined
Are we doing it wrong?
Looks like there is a way using
bootstrapStackRef.getOutput('userPoolExports').apply((userPool) => userPool.id)
Though it does create a bit more complexity for us downstream 😛
d
I think you should be able to do
getOutput('userPoolExports').id
directly, without the apply. You only need the apply if you're processing the data
e
Oh! I'll give that a try!
I don't think that works, since the type is
Output<any>
d
That's a limitation of getOutput (unsure why it's not generic). At runtime, it'll work
Output for attribute access uses a proxy to automatically do apply calls
e
Oh! That's good to know. Couple of workable options here.
Thanks for your help!
t
I've found a type annotation for stackref outputs helpful -
getOutput('foo') as pulumi.Output<typeof 'foo'>
e
I tend to avoid casting, but maybe that's the best way in this case?
d
Casting would be the way to go