You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting this validation error locally in my serverless.ts file:
Type '{ 'Fn::Split': string[]; }' is not assignable to type 'AwsCfInstruction[]'.
Object literal may only specify known properties, and ''Fn::Split'' does not exist in type 'AwsCfInstruction[]'.ts(2322)
index.d.ts(1331, 3): The expected type comes from property 'securityGroupIds' which is declared here on type 'AwsLambdaVpcConfig'
So I looked into the library code and couldn't find it mentioned anywhere. I saw the others though, like Fn::Join and the rest.
This brings my question, is the split method supported? Because I checked the later releases after v2.29.0 commit by commit and nothing was there(A change log would be really great by the way).
vpc: ({
securityGroupIds: {
'Fn::Split': [',', '${env:SECURITY_GROUP_IDS}'],
},
subnetIds: {
'Fn::Split': [',', '${env:SUBNET_IDS}'],
},
} as unknown) as AwsLambdaVpcConfig,
But I get this warning while deploying:
Serverless: Configuration warning:
Serverless: at 'provider.vpc.securityGroupIds': should be array
Serverless: at 'provider.vpc.subnetIds': should be array
Hi @omar-dulaimi and thanks for reporting your issue.
This repository aims to contains only TypeScript definitions compiled from Serverless core framework internal validation logic.
If you ignore the TS error showing that using Fn::Split is not a valid property for securityGroupIds, you'd still have the framework complaining about it (hence the warning you got on your second try).
Not a directly related question but I would appreciate your guidance. Now that type definitions are auto-generated, certain things are much clearer and certain things are not. Please take a look at stream event definition:
and serverless fails fast on functions.propagate.events[0].stream.arn': should be string with configValidationMode: 'error'. If I turn off configValidationMode, serverless package fails on EventSourceArn.split is not a function. This has been talked about long time ago here serverless/serverless#2365 and later fixed here serverless/serverless#3111.
So my question is - where to submit a PR or an Issue to get back those typed attributes into the generated type definitions? Adding type solved my problem but it would be nice if it was visible on the type def and thus accessible via auto-complete
Activity
[-]Fn::Join support?[/-][+]Fn::Split support?[/+]omar-dulaimi commentedon Apr 7, 2021
Okay, So I ended up doing this:
But I get this warning while deploying:
fredericbarthelet commentedon Apr 8, 2021
Hi @omar-dulaimi and thanks for reporting your issue.
This repository aims to contains only TypeScript definitions compiled from Serverless core framework internal validation logic.
If you ignore the TS error showing that using
Fn::Splitis not a valid property forsecurityGroupIds, you'd still have the framework complaining about it (hence the warning you got on your second try).I opened a PR aiming at allowing such use of Fn::Split, but I'm not sure wether additional development should be done in https://github.com/serverless/serverless/blob/dac06c8ce644f0d219329474cb83c644ca61d880/lib/plugins/aws/deployFunction.js#L283-L289 and https://github.com/serverless/serverless/blob/dac06c8ce644f0d219329474cb83c644ca61d880/lib/plugins/aws/package/compile/functions.js#L364-L376
pveller commentedon Apr 9, 2021
Not a directly related question but I would appreciate your guidance. Now that type definitions are auto-generated, certain things are much clearer and certain things are not. Please take a look at
streamevent definition:I do this:
and serverless fails fast on
functions.propagate.events[0].stream.arn': should be stringwithconfigValidationMode: 'error'. If I turn offconfigValidationMode, serverless package fails onEventSourceArn.split is not a function. This has been talked about long time ago here serverless/serverless#2365 and later fixed here serverless/serverless#3111.The fix was simple - adding an explicit
typeattribute to the stream event definition. DefinitelyTyped has it (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/serverless/plugins/aws/provider/awsProvider.d.ts#L408):but it's lost in auto-generated types:
So my question is - where to submit a PR or an Issue to get back those typed attributes into the generated type definitions? Adding
typesolved my problem but it would be nice if it was visible on the type def and thus accessible via auto-completeThanks!