Environment Variables available in your Alexa-hosted Skill

I found a simple article about environment variables that are available in Alexa-hosted Node.js Skills here: https://wp-kyoto.net/en/check-env-params-of-alexa-hosted-skills-2

I’m not sure how useful these parameters are for most Skill development, but it’s nice to know what is available for your Alexa-hosted Skill.

If you’re interested, simply add console.log(process.env) in your LaunchRequestHandler’s handle() method. Then, test your skill with the Test tab of the Alexa Developer Console or by using the dialog command of the Alexa ASK CLI. Head over to CloudWatch and see what you get!

Here’s what I see (some results are obfuscated with the X character for security):

{
    "S3_PERSISTENCE_BUCKET": "amzn1-ask-skill-XXXXXXXX-XXXX-buildsnapshotbucket-XXXXXXXXXX",
    "PATH": "/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin",
    "LD_LIBRARY_PATH": "/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib",
    "LANG": "en_US.UTF-8",
    "TZ": ":UTC",
    "LAMBDA_TASK_ROOT": "/var/task",
    "LAMBDA_RUNTIME_DIR": "/var/runtime",
    "AWS_REGION": "us-east-1",
    "AWS_DEFAULT_REGION": "us-east-1",
    "AWS_LAMBDA_LOG_GROUP_NAME": "/aws/lambda/XXXXXXXXXXXXX",
    "AWS_LAMBDA_LOG_STREAM_NAME": "2020/01/31/[143]XXXXXXXXXXXXXXXXX",
    "AWS_LAMBDA_FUNCTION_NAME": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXX",
    "AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "128",
    "AWS_LAMBDA_FUNCTION_VERSION": "999",
    "_AWS_XRAY_DAEMON_ADDRESS": "169.254.79.2",
    "_AWS_XRAY_DAEMON_PORT": "2000",
    "AWS_XRAY_DAEMON_ADDRESS": "169.254.79.2:2000",
    "AWS_XRAY_CONTEXT_MISSING": "LOG_ERROR",
    "_X_AMZN_TRACE_ID": "Root=X-XXXXXXXXXX-XXXXXXXXXXXXXXXXX;Parent=XXXXXX;Sampled=0",
    "AWS_EXECUTION_ENV": "AWS_Lambda_nodejs8.10",
    "_HANDLER": "index.handler",
    "NODE_PATH": "/opt/nodejs/node8/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules:/var/runtime:/var/task:/var/runtime/node_modules",
    "AWS_ACCESS_KEY_ID": "XXXXXXX",
    "AWS_SECRET_ACCESS_KEY": "XXXX/XXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "AWS_SESSION_TOKEN": "XXXXXXXXXXX+"
}

The most useful parameter here is S3_PERSISTENCE_BUCKET, which you will need to use if you store media files with your Alexa-hosted Skill. Here’s an example from the Alexa team’s Github repository: https://github.com/alexa/skill-sample-nodejs-consumable-hello-world/blob/master/lambda/custom/index.js#L800

The AWS_XRAY_* variables are also interesting. For more information on Amazon X-Ray, check it out here: https://aws.amazon.com/xray/. I wonder what is being analyzed…

Until next time, happy hacking!