silly-apple-46154
10/27/2023, 5:14 PMconst stackName = pulumi.getStack();
const programName = pulumi.getProject();
const idPrefix = `${programName
.split('-')
.map(p => p.charAt(0))
.join('')}-${stackName}`;
const currentStack = new pulumi.StackReference(stackName);
const cognitoUserPoolId = (
currentStack.getOutput(
`${idPrefix}-cognito-userPool`
) as pulumi.Output<aws.cognito.UserPool>
).apply(pool => {
console.log({ pool });
return pool?.id ?? 'us-east-2_DOQuLOIcm'
});
however, the value is always undefined... do i need to pass arguments to the stack reference or a provider or is there anything i am doing wrong here? the docs are not very clear on things here and i've attempted quite a few things but still dumbfounded 😕dry-keyboard-94795
10/27/2023, 5:52 PMsilly-apple-46154
10/27/2023, 5:52 PMdry-keyboard-94795
10/27/2023, 5:57 PMsilly-apple-46154
10/27/2023, 7:05 PMdry-keyboard-94795
10/27/2023, 7:10 PMexport
?silly-apple-46154
10/27/2023, 7:16 PMdry-keyboard-94795
10/27/2023, 7:16 PMuserPoolId
and clientId
. Unsure if you need it just for referencing, or for extra validation of the datasilly-apple-46154
10/27/2023, 7:17 PMexport default {
cognito: {
userPoolId: cognitoPool?.id,
clientId: cognitoClient?.id,
domainId: cognitoDomain?.id,
},
};
and then can reference by using:
const organizationName = pulumi.getOrganization();
const stackName = pulumi.getStack();
const programName = pulumi.getProject();
const currentStack = new pulumi.StackReference(stackName, {
name: `${organizationName}/${programName}/${stackName}`,
});
const cognitoOutputParams : {
clientId: string;
domainId: string;
userPoolId: string;
} | undefined = await currentStack.getOutputValue('cognito');
export class Provider extends AWSProvider {
regionName: string;
constructor(name: string, args?: ProviderArgs, opts?: ResourceOptions) {
super(name, args, opts);
this.regionName = args!.region as string;
}
dry-keyboard-94795
10/27/2023, 7:25 PMsilly-apple-46154
10/27/2023, 7:26 PMdry-keyboard-94795
10/27/2023, 7:29 PMsilly-apple-46154
10/27/2023, 7:47 PMdry-keyboard-94795
10/27/2023, 7:51 PMconst foo = pulumi.Output.create("foo");
console.log(await (foo as any).isKnown as Promise<boolean>);
console.log(await (foo as any).promise());
This seems to work. Relies on Output being an alias to `OutputImpl`: https://github.com/pulumi/pulumi/blob/202491bfea6af05adc505d41a5166e7db9bbdee3/sdk/nodejs/output.ts#L952true
then foo
.
However you probably shouldn't do this in any production code 🙂silly-apple-46154
10/27/2023, 7:52 PM