This project deploys an Alexa skill to interact with The movie database using an AWS Lamba.
Right now the integration with TMDB is pretty simple, just allowing request movie ratings in spanish.
This project pretends to teach how to deploy Elixir application into AWS lambdas, as well how to create any Elixir integrations with Alexa.
Get dependencies with mix deps.get
and run mix test
You will need:
- docker
- elixir
- asdf (recommended, not mandatory)
- awscli
To be able to deploy the lambda to AWS, you will need:
- Go to the IAM console
- Add new user
- Add the policy roles:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1482712489000",
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:PutRolePolicy",
"lambda:CreateFunction",
"lambda:InvokeAsync",
"lambda:InvokeFunction",
"iam:PassRole",
"lambda:UpdateAlias",
"lambda:CreateAlias",
"lambda:GetFunctionConfiguration",
"lambda:AddPermission",
"lambda:UpdateFunctionCode"
],
"Resource": [
"*"
]
}
]
}
- Create a new access key
- Run
aws configure
and pat your credentials
Create an Alexa skill and create an intent to ask for a movie rating.
You will need to use a slot name movie_name
.
Create a role which the permissions AWSLambdaMicroserviceExecutionRole
and AWSLambdaBasicExecutionRole
.
This role will be used to execute the lambda.
An api key from TMDB is needed, and it will be need into config/config.secret.exs
:
import Mix.Config
config :tmdb,
api_key: "replace_this_with_your_tmdb_api_key"
An .env file will be used to get your AWS lambda info:
name | description |
---|---|
AWS_REGION | AWS region where the lambda is created |
ROLE_ARN | Role ARN which was created to execute the lambda |
LAMBDA_NAME | The lambda name |
ALEXA_SKILL_ID | The Alexa skill id |
To create an AWS lambda release, package into a zip, run the target make docker_package
.
This target will use a Docker container to generate the Erlang binaries compatible with AWS, and the generated result will be copied to the /output
directory.
Once the release is generated, you can create an AWS lambda by executing make create_lambda
.
This will upload the lambda package to AWS, which will be excuted by demand.
Once the lambda is created, it can be updated at any time running the target make update_lambda
.
The lambda can be invoked with test data by running make test_lambda
.
This target can be used to verify the lambda deployment and is not its intention to test the Alexa skill.