Giter VIP home page Giter VIP logo

aws-batch-python-runner's Introduction

aws-batch-runner

This repo represents a Proof of Concept for using AWS Batch to run a python-based cli on a as-needed basis.

Includes gb-util which simulates "ingestion" of books from the "recent" feed on Project Gutenberg

Prerequisite Installations

  • Terraform
  • Python: tested with 3.8
  • pyenv: highly recommended for working with multiple versions of Python.

Deploying the Infrastructure

pushd infrastructure
terraform init
terraform import aws_cloudwatch_log_group.aws_batch_job_log_group /aws/batch/job
popd

Running the cli

pushd src
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt

# for development
pip install -r requirements-dev.txt

python gb-util.py --help

Docker

# build the image
docker build ./src -f ./src/Dockerfile -t gb-util:latest

# run it
docker run --rm gb-util:latest --help

Deploy a new version

TODO: make this less error-prone

# 1. Review current version `app_image` var in `./infrastructure/variables.tf`
# 2. increment using semantic versioning: `export VERSION=x.x.x
# 3. build
docker build ./src -f ./src/Dockerfile -t gb-util:latest
# 4. tag
docker tag gb-util:latest krcourville/gb-util:${VERSION}
# 5. push
docker push krcourville/gb-util:${VERSION}
# 6.update Batch Job Definition:
pushd infrastructure
export TF_VAR_image_version=$VERSION
terraform apply
popd
# 7.commit changes
git add... git commit...etc..
# 8. tag the repo:
git tag $VERSION && git push --tags

References

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.