question

Junda avatar image
Junda asked

How to set environment variables for external API keys in AWS Lambda hosted Alexa Skill?

My Alexa skill extracts data from an external API, and hence I need to use a API key there. AWS recommends we use environment variables in Lambda for API keys, but when choosing the Lambda hosted option for my Alexa skill, I don't see the function in my Lambda. How can I set up the environment variable in this case?

alexa skills kitlambda
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

djohnsonkc avatar image
djohnsonkc answered

I'm looking for answer to this question as well. The process.env variable provides a lot of information, but nothing stood out as a test/prod indicator.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

djohnsonkc avatar image
djohnsonkc answered

In the absence of a better solution, I am currently using a config file to set the environment. That way, when I submit for release, I only have to change "qa" to "prod" in one place before the submission. It's a dangerous solution, but seems to be the only option that allows us to straddle two separate skills and keep them cloned. Along with this approach, we are going the route that it seems like other developers are going with Alexa-hosted skills by having a separate testing and production skill. With the separate skills, we can just set our config file to "qa" or "prod" independently. I sure wish process.env exposed something that told us what environment or git branch the app is associated with. Would make life much easier.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.