https://pulumi.com logo
#general
Title
# general
f

full-dress-10026

08/06/2019, 12:57 AM
createNodeGroup
on a
eks.Cluster
takes an
instanceType
parameter which must be a
aws.ec2.InstanceType
. I'd like to pass in a string from a config file. How can I do this without Typescript complaining?
b

big-piano-35669

08/06/2019, 1:03 AM
If the string is in a variable named, say,
instanceType
, you would say either
createNodeGroup(..., instanceType as aws.ec2.InstanceType, ...)
or
createNodeGroup(..., <aws.ec2.InstanceType>instanceType, ...)
. This simply asserts the type, it doesn't actually check that it's a valid instance type. More info here https://www.typescriptlang.org/docs/handbook/basic-types.html#type-assertions.
f

full-dress-10026

08/06/2019, 1:04 AM
Yep, that does it. Thank you!
👍 1