Serverless-offline: Support for cross stack references

Created on 5 Apr 2018  路  8Comments  路  Source: dherault/serverless-offline

I'm not sure if this is supported, but I didn't see anything in the documentation about it. I have 2 services, one that imports a value from the other using ${cfcr: ... } (https://www.npmjs.com/package/serverless-plugin-cloudformation-cross-region-variables). When I start up the services locally, the one that imports the variable exits since it has no idea where to find this value.

Is it possible to do this with Serverless Offline? At the very least, is it possible to do it with the built in ${cf: ... }? Thanks for the help in advance!

enhancement question

Most helpful comment

Would be fantastic

All 8 comments

As far as I can tell, this is currently a limitation of serverless-offline.

The following works online for me, but doesn't work offline.

Stack A:
  Outputs:
    VideosS3Bucket:
      Value:
        "Ref": VideosS3Bucket
      Export:
        Name: ${self:service}-VideosS3Bucket-${self:provider.stage}

Stack B:
  environment:
    VIDEOS_BUCKET:
      "Fn::ImportValue": "eduo-resource-stack-VideosS3Bucket-${self:provider.stage}"

The env var ends up as a string with the value "[object Object]". Literally its value.

Do any "Fn::" functions that access online content work with serverless-offline?

Any word on this?

We'd be open to sponsoring the work to have this addressed quickly. @dherault is that something you'd be open to?

Hi @dvins
At the moment I cannot say I have time to work on it. But we'd gladly accept a PR addressing this.

Would be fantastic

This could be another feature for the serverless-cloudside-plugin. Support for "Fn::ImportValue" is already being added via pull request, so support for ${cfcr:...} should be easy to add as well.

I have a similar / same question. Had to split my services due to 200 resources limit like described here: https://www.gorillastack.com/news/splitting-your-serverless-framework-api-on-aws/ But now my authorizers wont work offline anymore because they come back as [object Object] and this warning: WARNING: Serverless Offline does not support non local authorizers (authorizerId): [object Object]

I exported them in my main (resources) service and tried to load them like this:

custom:
  authorizer:
    type: CUSTOM
    authorizerId:
      Fn::ImportValue: ${self:provider.stage}-ApiGatewayAuthorizerId

This looks impossible right now. So is there any solution to this?! I mean this is nothing super special. Mostly every project needs authorizers and a split service architecture. Thanks for ya help!

I just want to add that ${cf} syntax is not a substitute for supporting ImportValue. ImportValue is resolved at AWS deploy time, ${cf} is resolved at severless YML parse time. If a serverless plugin creates a separate stack as part of the deploy process, ${cf} will blow up because it is in effect a circular dependency, but ImportValue would work fine. (Offline would still encounter an error that the export doesn't exist, but using ${cf} for this would prevent you from deploying)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

conradoramalho picture conradoramalho  路  3Comments

adambiggs picture adambiggs  路  4Comments

ktwbc picture ktwbc  路  4Comments

ghost picture ghost  路  4Comments

mattmeye picture mattmeye  路  4Comments