Coder Social home page Coder Social logo

Add 'package' command about zappa HOT 11 CLOSED

miserlou avatar miserlou commented on May 13, 2024 5
Add 'package' command

from zappa.

Comments (11)

Miserlou avatar Miserlou commented on May 13, 2024 1

I was thinking that it would be a settings entry for each function.

Although, to be honest, I think my longer term vision would be that non-APIGW lambda functions could simply be wrapped as decorators as a way to replace Celery, etc, so you could do something like

@zappa(event_source="ses:blah")
def mail(event):
    return True

or for scheduled events:

@zappa(timing="0 0 0 * * *")
def defrag(event):
    return True

and have these functions created and configured automatically with deploy/update.

But I've held off on implementing that since lambda scheduling can't be done via API/boto yet. Thoughts?

from zappa.

ubiquitousthey avatar ubiquitousthey commented on May 13, 2024

I started a fork to add the package and/or upload functionality. I got stuck where I needed to figure how how to do the settings. The settings file really needs to change so that one can define most of the environment settings on individual functions with an additional handler setting. How do you see this working? I am thinking something like:

{
    "dev": { // The name of your environment
       "app" : {
         "s3_bucket": "lmbda", // The name of your S3 bucket
         ... // Various lambda attributes
         "app_function": "your_module.app" // The python path to your WSGI application function.
       },
       "my_function" : {
         "s3_bucket": "lmbda", // The name of your S3 bucket
        ... //Various Lambda attributes
         "handler": "module.function" // The handler for the lambda function
       }
    }
}

I think it would be pretty easy to handle both the old-style and new-style. If there is an "app" key in the dictionary, load as new-style, if not load as old-style.

Your thoughts?

from zappa.

Miserlou avatar Miserlou commented on May 13, 2024

Hi ubiquitousthey - thanks for bringing this up.

I think that might be over-engineering it a bit. I don't think an environment would have a both an app_function and a handler - just one or the other, with app_function taking precedent over handler. Does that make sense, or is there a scenario I'm missing?

from zappa.

ubiquitousthey avatar ubiquitousthey commented on May 13, 2024

I have an system I am working on that will have a web component that I would develop with zappa/flask. It also will have a few lambda functions that get triggered by SES and a timer. I was thinking it would have a configuration like the one above.

In this case I was thinking one could issue:
zappa dev deploy or
zappa dev deploy app or
zappa dev deploy my_ses_handler

This could also be accomplished with an environment per function or app as well, and that could leave the format pretty much the same and simplify the changes to the code, but it would push toward environments that would result in command like:

zappa app-dev deploy and
zappa my_ses_handler-dev deploy

which would result in some uglier function and apig names.

Maybe the the idea would be to have one settings file per app or function?

from zappa.

ubiquitousthey avatar ubiquitousthey commented on May 13, 2024

One zapp_settings file per function sounds reasonable.

The decorators sound interesting. I like being able to define the triggers in code. There might need to be a way to configure environment. One might have 2 SNS topics: one for testing and one for production. I suppose the precompile step could be used to load settings from a renamed json or py.

I think the lambda schedule is available now as a cloud watch event.
http://boto3.readthedocs.io/en/latest/reference/services/events.html?highlight=cloud%20watch%20event#CloudWatchEvents.Client.put_rule

You would have to call put_rule and put_target.

from zappa.

Miserlou avatar Miserlou commented on May 13, 2024

Ooo.. excellent find. Cool.

from zappa.

Miserlou avatar Miserlou commented on May 13, 2024

Keep-Warm using CloudWatch Events is now in Master.

from zappa.

ubiquitousthey avatar ubiquitousthey commented on May 13, 2024

Cool. I'll create a PR for the settings-per-function idea as that moves me forward. I'll look at the decorator idea after that.

from zappa.

Miserlou avatar Miserlou commented on May 13, 2024

You are actually already be able to specify a different settings file using the '-s' argument.

from zappa.

kpx-dev avatar kpx-dev commented on May 13, 2024

I think we should model this CLI similar to docker:
zappa build
zappa push
..etc

Each function can have its Zappafile settings

from zappa.

Miserlou avatar Miserlou commented on May 13, 2024

Thanks @michi88 for implementing this

from zappa.

Related Issues (20)

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.