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

helpful-afternoon-80621

08/14/2019, 11:13 AM
Any reason why the example from the typescript ec2.SecurityGroup source fails to typecheck?
Copy code
const allowTls = new aws.ec2.SecurityGroup('allowTls', {
  description: 'Allow TLS inbound traffic',
  ingress: [
    {
      cidrBlocks: '', 
      fromPort: 443,
      protocol: 'tcp',
      toPort: 443
    }
  ],
  tags: {
    Name: 'allowAll'
  }
});
I'm getting a long cryptic typescript error that isn't much use in indicating what is actually wrong.
Copy code
Error:(12, 56) TS2345: Argument of type '{ description: string; ingress: { cidrBlocks: string; fromPort: number; protocol: string; toPort: number; }[]; tags: { Name: string; }; }' is not assignable to parameter of type 'SecurityGroupArgs'.
  Types of property 'ingress' are incompatible.
    Type '{ cidrBlocks: string; fromPort: number; protocol: string; toPort: number; }[]' is not assignable to type 'Input<{ cidrBlocks?: Input<string>[] | Promise<Input<string>[]> | OutputInstance<Input<string>[]> | undefined; description?: string | Promise<string> | OutputInstance<string> | undefined; ... 6 more ...; toPort: Input<...>; }>[] | Promise<...> | OutputInstance<...> | undefined'.
      Type '{ cidrBlocks: string; fromPort: number; protocol: string; toPort: number; }[]' is not assignable to type 'Input<{ cidrBlocks?: Input<string>[] | Promise<Input<string>[]> | OutputInstance<Input<string>[]> | undefined; description?: string | Promise<string> | OutputInstance<string> | undefined; ... 6 more ...; toPort: Input<...>; }>[]'.
        Type '{ cidrBlocks: string; fromPort: number; protocol: string; toPort: number; }' is not assignable to type 'Input<{ cidrBlocks?: Input<string>[] | Promise<Input<string>[]> | OutputInstance<Input<string>[]> | undefined; description?: string | Promise<string> | OutputInstance<string> | undefined; ... 6 more ...; toPort: Input<...>; }>'.
          Type '{ cidrBlocks: string; fromPort: number; protocol: string; toPort: number; }' is not assignable to type '{ cidrBlocks?: Input<string>[] | Promise<Input<string>[]> | OutputInstance<Input<string>[]> | undefined; description?: string | Promise<string> | OutputInstance<string> | undefined; ... 6 more ...; toPort: Input<...>; }'.
            Types of property 'cidrBlocks' are incompatible.
              Type 'string' is not assignable to type 'Input<string>[] | Promise<Input<string>[]> | OutputInstance<Input<string>[]> | undefined'.
Running v0.17.28. Thanks
Found the issue. The cidrBlocks field should have been an array.
b

broad-dog-22463

08/14/2019, 11:44 AM
sorry that error isn't more useful @helpful-afternoon-80621
l

lemon-spoon-91807

08/14/2019, 10:19 PM
Yeah, this is an unfortunate Typescript-ism