Following the instructions here:
https://docs.deno.com/runtime/tutorials/aws_lambda/
Reproducing some of those docs here for convenience but if you have any issues reference the docs
Leverages the aws-lambda-adapter
and docker
- Build the docker image
docker build -t hello-world .
- Create the ECR repository + push (note: change region as needed)
AWS_REGION=us-west-2
aws ecr create-repository --repository-name hello-world --region $AWS_REGION | grep repositoryUri
This should output a repository URI that looks like <account_id>.dkr.ecr.us-west-2.amazonaws.com/hello-world.
then:
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin <account_id>.dkr.ecr.us-west-2.amazonaws.com
Tag the Docker image with the repository URI, again using the repository URI from the previous steps:
docker tag hello-world:latest <account_id>.dkr.ecr.us-west-2.amazonaws.com/hello-world:latest
Finally, push the Docker image to the ECR repository, using the repository URI from the previous steps:
docker push <account_id>.dkr.ecr.us-west-2.amazonaws.com/hello-world:latest
Now you can create a new AWS Lambda function from the AWS Management Console.
- Go to the AWS Management Console and navigate to the Lambda service.
- Click on the "Create function" button.
- Choose "Container image".
- Enter a name for the function, like "hello-world".
- Click on the "Browse images" button and select the image you pushed to ECR.
- Click on the "Create function" button.
- Wait for the function to be created.
- In the "Configuration" tab, go to the "Function URL" section and click on "Create function URL".
- Choose "NONE" for the auth type (this will make the lambda function publicly accessible).
- Click on the "Save" button.
-
You can now visit your Lambda function's URL to see the response from your Deno app.
-
🦕 You have successfully deployed a Deno app to AWS Lambda using Docker. You can now use this setup to deploy more complex Deno apps to AWS Lambda.
- First time through creating the function use the steps above
- after that, you can use the deploy helper:
deploy.sh
- deploys the function to AWS Lambda, just pass the folder name as an argument- to add a new function, copy the folder and change the dockerfile as needed
- NOTE: AWS region
us-west-2
is hardcoded in the deploy script, change as needed