Any reason why the example from the typescript ec2...
# general
h
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
sorry that error isn't more useful @helpful-afternoon-80621
l
Yeah, this is an unfortunate Typescript-ism