https://pulumi.com logo
Title
w

wide-holiday-59376

09/09/2019, 2:06 PM
I want to read the machine type from environment variables but pulumi is expecting a
InstanceType
and I cannot figure out how to cast from one to the other.
s

stocky-island-3676

09/09/2019, 2:09 PM
Use
<aws.ec2.InstanceType> stringVariable
. E.g.
<aws.ec2.InstanceType> config.get("instanceType")
(copied from https://github.com/pulumi/examples/blob/master/aws-ts-ruby-on-rails/config.ts#L41)
w

wide-holiday-59376

09/09/2019, 2:11 PM
That worked. Thank you.
b

broad-dog-22463

09/09/2019, 3:06 PM
FYI, I have opened this PR to relax this requirement
this will allow the aws.ec2.InstanceType or a string representation of it
w

wide-holiday-59376

09/09/2019, 3:35 PM
To be fair, this only tripped me up because I'm new to Typescript. I prefer types be strong-typed if possible. Had I known how to cast I would have just done so.
s

stocky-island-3676

09/09/2019, 3:38 PM
@wide-holiday-59376 Nice to hear. I’m also in to have more types in Pulumi than less. Maybe you want to follow the PR, as well? Just added my 2 cents there.
w

wide-holiday-59376

09/09/2019, 3:42 PM
Will do, thanks.