omnius45467 / geekwise-alexa-course

Geekwise Amazon Alexa Skills Course
0 stars 2 forks source link

Automation of deploys through the aws cli #20

Closed omnius45467 closed 8 years ago

ngrices commented 8 years ago

Here is some boilerplate code for updating the skill via the cmd line I use the AWS CLI (https://aws.amazon.com/cli/) to submit the code as a zip file. You have to use S3 if you go past 10MB. Here’s a bash script for uploading a zip:

!/bin/bash

zip the skill

pushd skill zip -r ../skill.zip * popd

deploy it

sudo aws lambda update-function-code --function-name Skill --zip-file fileb://skill.zip

test it

sudo aws lambda invoke --function-name Skill --payload file://skill/test.json output.txt cat output.txt echo sudo rm output.txt

Here’s one for using S3:

!/bin/bash

zip the skill

pushd skill rm ../skill.zip zip -r ../skill.zip * popd

deploy it

sudo aws s3 cp skill.zip s3://skill-bucket/ sudo aws lambda update-function-code --function-name Skill --s3-bucket skill-bucket --s3-key skill.zip

test it

sudo aws lambda invoke --function-name Skill --payload file://skill/test.json output.txt cat output.txt echo sudo rm output.txt

The test parts assume there’s a JSON file in the skill’s root directory called test.json that’s a valid Lambda event for testing the skill.

omnius45467 commented 8 years ago

This has been added to day 3, on day 4 and 5 we will be exploring a library/boilerplate that another has developed that uses grunt to automatically deploy to AWS.