I'm doing this: ```export const getSigningKey = ( ...
# typescript
b
I'm doing this:
Copy code
export const getSigningKey = (
        secretKey: string | pulumi.Output<string>,
        region: pulumi.Output<digitalocean.Region | aws.Region>
) => {...};

if (cloud === 'digitalocean') {
  s3 = new digitalocean.SpacesBucket(env, {
    region: awsRegion,
  });
} else if (cloud === 'aws') {
  s3 = new aws.s3.Bucket(env, {
    region: awsRegion,
  });
}
signingKey = getSigningKey(
  awsSecretKey,
  s3!.region
);
this doesn't work. it complains that the types for
region
don't match. anyone know why?
t
Because they are different types from TypeScript pov. You’d need to add a type check/convertion.
g
Your type should be:
Copy code
export const getSigningKey = (
        secretKey: string | pulumi.Output<string>,
        region: pulumi.Output<digitalocean.Region> | pulumi.Output<aws.Region>
) => {...};
You accept either of the two outputs, not an output that can resolve to one of those regions
Also, it would be better if you use
pulumi.Input
as it includes passing the internal type directly or with a promise. Then in your function you can use
pulumi.output(region)
b
@green-school-95910 thanks, you're right that was an error on my part to not distinguish between either of two outputs and an output that could resolve to either. much appreciated.