Beginner questions

Hi everyone,

I have just started using Serverless to do some node.js Lambda coding and I am making slow progress as I have to learn a lot.

One of the things that I am unsure of is whether I am able to make references in my Lambda code to resources in the Serverless CF Stack. For example, Serverless has created a sns endpoint for me and I can see the Topic ARN as Logical ID smsSNSEvent0 in the stack but I do not know how to reference it in my code and therefore currently have the Topic ARN hardcoded in the params that I pass to AWS.SNS.publish(). Is there a way in which I do not have to hardcode resource IDs but can take it from the Stack?

I also would like to know how I can reference things like the service name and the stage name within JSON files that are $ref’ed in serverless.yml. I $ref a custom_resources.json in my serverless.yml which, amongst other things, contains DynamoDB Table names in format servicename-entity-stagename so something like myservice-posts-dev. It would be great if it could be written as ${service}-posts-${stage} or something similar so that when I for example deploy in a new stage, the DynamoDB Table names are automatically correct and unique for that stage. Additionally, I’d like to reference servicename, stagename and region in my code easily as well.

Are these things currently possible or perhaps in upcoming versions? I apologise if this is already in the docs but I failed to find it there. I also apologise if the forum is not the correct medium for these kind of questions.

Thanks for any help and kudos on the great work with Serverless!

Hi,

all of this will be possible with upcoming changes. You can follow the pull request here: http://github.com/serverless/serverless/pull/1834

I can’t give exact details how all of those features will work as we’re currently implementing them, but both use cases you mentioned are very important for us.

best,
Flo

1 Like

Hi Flo,

Excellent, that is very good to hear! I will monitor that issue closely, thank you for your reply.