https://pulumi.com logo
#typescript
Title
# typescript
b

bitter-dentist-28132

02/05/2020, 6:37 PM
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

tall-librarian-49374

02/05/2020, 7:48 PM
Because they are different types from TypeScript pov. You’d need to add a type check/convertion.
g

green-school-95910

02/05/2020, 9:32 PM
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

bitter-dentist-28132

02/10/2020, 5:40 PM
@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.
6 Views