Giter Site home page Giter Site logo

nickchecan / python-lambda Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 3 KB

A python Docker container that will generate an image to be stored at the AWS ECR and implemented as a AWS lambda function

Dockerfile 40.98% Python 59.02%
python docker docker-image docker-file aws aws-lambda

python-lambda's Introduction

Python Lambda

This is a very simple project to deploy a Docker container image as an AWS lambda function using Python and some other libraries that will communicate with AWS S3 and other services.

Important Commands

Build the docker image:

docker build -t python-lambda .

Connect to the AWS ECR service:

aws ecr get-login-password --region {Your region code} | docker login --username AWS --password-stdin {URI from the AWS ECR Repository}

Tag your image with the docker images repository information:

docker tag {URI from the AWS ECR Repository}

Push the code to the AWS ECR:

docker push {URI from the AWS ECR Repository}

All of these mentioned codes can be found on the ECR service within the images repository through the View push commands button. It's important to have the ECR created before trying to push anything to the Amazon Web Services.

If the pushing command display any errors, you can login and link back your AWS/Docker account through the following command:

aws ecr get-login-password \
  --region <region> \
| docker login \
  --username AWS \
  --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com

AWS Lambda Runtime Interface Emulator (RIE)

To test the container locally, it is possible to take advantage of the RIE. The AWS base images for Lambda include the runtime interface emulator. If needed, alternative base images can be used. More work will be necessary to build the RIE on those images in order to test the application locally, though.

More information can be found on the optional references at the end of this document.

For tests, you can run the container with the following command:

docker run -p 9000:8080 python-lambda:latest

This command runs the image as a container and starts up an endpoint locally at localhost:9000/2015-03-31/functions/function/invocations.

Now you can post an event to the following endpoint using a curl command:

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'

References

The links bellow describes the procedures followed to deploy the Docker image on ECR and use it for the creation of the lambda function.

Optional

python-lambda's People

Contributors

nickchecan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.