Skip to content

Instantly share code, notes, and snippets.

@rvargs
Created October 5, 2019 15:09
Show Gist options
  • Save rvargs/3108f03ac377d6f53c22e0e08445cae9 to your computer and use it in GitHub Desktop.
Save rvargs/3108f03ac377d6f53c22e0e08445cae9 to your computer and use it in GitHub Desktop.
AWS SLS example with Alexa fn.sh
# Create AWS credentials file in ~/.aws
serverless config credentials --provider aws --key <access-key-id> --secret <secret> --profile <profilename>
# Create a sls framework service from a template in a path called servicename
serverless create --t aws-nodejs --path servicename
# Deploy functions from serverless.yml to AWS Lambda
sls deploy
# Invoke function
sls invoke -f <function-name-in-serverless.yml>
# Invoke function locally - Meaning you won't get hit by fees but also won't work if it depends on data from S3, DynamoDB, etc..
sls invoke local -f <function-name-in-serverless.yml>
# Show logs of a function
serverless logs -f <function-name-in-serverless.yml>
# Tail logs of a function
serverless logs -f <function-name-in-serverless.yml> --tail
# Sample config for an Alexa AWS function
service: serverless-alexa-aws-test # resulting function name in AWS Lambda
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: eu-west-1 # Ireland
profile: my-aws-credentials-profile
functions:
alexatestskill:
handler: handler.alexatestskill # in this example, the file is handler.js, and the function name is alexatestskill()
events:
- alexaSkill
package:
exclude:
- node_modules/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment