Return undefined with new variable resolver engine

We’re trying to migrate from the v2 variable resolvers to the new v3 variable resolver engine. I’m struggling with how to return undefined values (i.e. my resolver can’t resolve).

If I return { value: undefined }, serverless gives error:
Source "xyz" returned not supported result: "undefined"

If I return just undefined (i.e. not wrapped in { value }), serverless gives error:
Unexpected "xyz" source result: undefined

If I return { value: null }, serverless gives error:
Value not found at "xyz" source

For context, I want to use this to pass an optional parameter:

    MyLayer:
      Type: AWS::Lambda::LayerVersion
      Properties:
        Content:
          S3Bucket: ${myresolver:bucket, ''}
          S3Key: ${myresolver:key, ''}
          S3ObjectVersion: ${myresolver:objectVersion}

Any advice?

1 Like

Getting the same problem. It also happens when resolving ssm secrets that don’t exist. It fails rather than using the provided default ’ ’

Blocking deployment now.

Ok found a solution by looking at how serverless do it. If your variable doesn’t exist your resolve needs to

return { value: null} 

It looks like you’ve tried this, so unclear why you still get an error.