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

elegant-crayon-4967

06/11/2019, 7:46 PM
[Solved] When using
import * as aws from "@pulumi/aws";
command, I get errors assigning values via a variable to my ec2 instanceType, but if I use the old format
const aws = require("@pulumi/aws")
the error goes away and my code runs just fine. Thoughts?
g

gentle-diamond-70147

06/11/2019, 7:48 PM
What error do you get?
e

elegant-crayon-4967

06/11/2019, 7:49 PM
I have
let size = "t2.micro"
and then calling that later as
instanceType: size
error I get is
Type 'string' is not assignable to type 'Input<InstanceType>'.ts(2322)
but only when I use that import command instead of the require
w

white-balloon-205

06/11/2019, 8:13 PM
Yes - when you use
import
you get strong typing, when you use
require
you don’t get any type checking. In this case you can appease TypeScript by saying
let size: aws.ec2.InstanceType = “t2.micro”
.
e

elegant-crayon-4967

06/11/2019, 8:14 PM
aah, thank you. clearly I am new to both typescript & pulumi
3 Views