Giter Club home page Giter Club logo

blambda's Introduction

blambda

Balihoo Lambda deploy tools

installation

pip install git+https://github.com/balihoo-gens/blambda.git

configuration

First, make sure your AWS credentials are set up Then configure at least these two variables:

blambda config region us-east-1
blambda config role 'arn:aws:iam::etcetera'

you can also set the variables 'application' and 'environment' which will automatically be prepended and appended to your function name. my_function would turn into myapp_my_function_myenv for example.

create a new AWS Lambda function:

blambda new new_thing will get you a directory called 'new_thing' containing new_thing.py and new_thing.json you can provide--runtime coffee to create a new coffee script function.

The json file is your manifest, which can look like:

{
    "blambda": "manifest",
    "dependencies": {
        "tldextract": "2.0.1"
    },
    "options": {
        "Description": "test_thing",
        "Runtime": "python2.7",
        "Timeout": 300
    },
    "permissions": [
      {
          "Effect": "Allow",
          "Action": "route53:ChangeResourceRecordSets",
          "Resource": "arn:aws:route53:::hostedzone/SAKJHAUHIS"
      }
    ],
    "schedule": {
        "input": { "things": "stuff" },
        "rate": "1 minute"
    },
    "source files": [
        "test_thing.py",
        "my_other_file.py"
    ]
}

you can add dependencies with an explicit version, and permissions as IAM statements source files can be relative paths, and can be a tuple with (local, remote) name, so you can pull in shared files

setting up your deps

before deploying, your dependencies need to be installed. This is a separate step because you do not need to do this as often.

blambda deps new_thing

For Python, you can choose to have them installed in/with whatever python environment you are in, or to set up an AWS Lambda equivalent 2.7 environment specifically for your function. The latter is convenient for local testing to avoid missing dependencies

blambda deps new_thing --ve

deploying your function

Deploy sets up your lambda function as well as any IAM roles, CloudWatch Events schedules etc.

blambda deploy test_thing

running your function

You can run your function right from the commandline

blambda exec test_thing

will take a json payload from stdin, so

cat payload.json | blambda exec test_thing

will send the contents of payload.json to the deployed test_thing lambda function

blambda exec test_thing --payload '{ "my": "payload"}'

will do the same as:

echo '{ "my": "payload"}' | blambda exec test_thing --payload

Seeing the logs

blambda logs new_thing

will get you the cloudwatch log messages (== function stdout) from your function for recent executions. logs has many options, that you can see with blambda logs --help. In short, you can specify different output formattings, summary and date/time range

stale functions

Sometimes, you forget what is deployed in lambda and how far out of date it is with your current repo. Blambda can help you with this by asking it to check for 'stale' functions:

blambda stale

will tell you which functions are out of date compared to the current repo HEAD. Supplying the -v (verbose) option will also tell you which files are out of date.

blambda's People

Contributors

balihoo-gens avatar ghe avatar

Watchers

 avatar

Forkers

ghe balihoo

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.