Skip to content

Move packaging process into own plugin #1486

Closed

Description

@pmuens

The packaging process should be moved into an own plugin.

Status:
Done --> See #1494

This includes:

  • Zipping up a whole service
  • One service equals one zip file which includes all the necessary code (all functions)
    • Magic handler support will be dropped (as it's not necessary anymore)
  • There will be no checksum to check if something has changed
    • The zipped up service will be redeployed every time (this ensure that the build "will always work" as no brittle steps as e.g. checksum support will be implemented)
  • Possibility to set a path to an own artefact (.zip file) via a definition in the serverless.yaml file (e.g. artefact_path). This way the deployment plugin will use the user specified artefact and won't zip up everything on it's own

Questions:

  • Do we need an own lifecycle in the deploy plugin? Or should we use before:deploy:deploy?

Current implementation:
The current implementation can be found in the awsDeploy plugin.

Open issues:

Activity

  1. added this to the v1.0.0-alpha.2 milestone on Jul 5, 2016
  2. self-assigned this
    on Jul 5, 2016
  3. added a commit that references this issue on Jul 5, 2016
  4. flomotlik commented on Jul 5, 2016

    @flomotlik
    Contributor

    @pmuens imho we should have a package step. This makes sure other plugins can hook in there as well.

    And the way to let following plugins know which artefact path they should use could simply be a configuration value in the serverless.yml, e.g.

    artefact_path:
    

    By default people don't set it, the packaging plugin zips and puts this somewhere to be picked up, but if users want to build their own artefact they can and if the artefact_path variable is present the packaging plugin will simply do nothing.

  5. pmuens commented on Jul 5, 2016

    @pmuens
    ContributorAuthor

    @flomotlik Sound reasonable.

    Should the package lifecycle be included in the deploy plugin (deploy:package) and an own package plugin which hooks into this lifecycle and implements the packaging process?

    Or should we define a package plugin which has a package:package lifecycle and the packaging implementation?

  6. flomotlik commented on Jul 5, 2016

    @flomotlik
    Contributor

    Imho has to be in deploy, otherwise it won't run as people would have to run package:package directly. but we can implement a separate package command in the future imho.

  7. pmuens commented on Jul 5, 2016

    @pmuens
    ContributorAuthor

    Yep. Missed that package:package yields to the fact that we need an own command.

    Here's how this might look like:

    lifecycleEvents: [
      'initializeResources',
      'createProviderStacks',
      'compileFunctions',
      'compileEvents',
      'createDeploymentPackage',
      'deploy',
    ],
    

    Not sure if we should name it createDeploymentPackage or just package (I like names that speak for themselves 😆 )

  8. flomotlik commented on Jul 5, 2016

    @flomotlik
    Contributor

    createDeploymentPackage sounds good to me

  9. license2e commented on Jul 5, 2016

    @license2e
    Contributor

    @pmuens @flomotlik the only downside I see to this is the size of zip file... For example, one of the current functions we have written in Java with all the jars is 38MB, and the limit is 50MB...

    Would we have to separate out into different services and then keep track which lambda function has which handler?

    There doesn't seem a logical way to separate out the functions and services...
    We have different department (companies), languages and aws services.

    Also, it would seem like function type would have to be per services not per function, is that correct?

  10. flomotlik commented on Jul 5, 2016

    @flomotlik
    Contributor

    @license2e Is that only one function or are those 38MB combining code for multiple functions? We do want to provide a way in the future for you to build function specific packages, would be great to understand a little more how you're reusing code in services.

  11. license2e commented on Jul 5, 2016

    @license2e
    Contributor

    Unfortunately one function, although, its currently pulling in ALL AWS SDK jars, so I will have to tweak the gradle zip settings to only pull in the ones that are actually used...

  12. eahefnawy commented on Jul 6, 2016

    @eahefnawy
    Contributor

    While I like the simplicity this introduces (for us and for our users), this will make deployment exponentially slow, and will eat up lots of space both on S3 and Lambda, which is the main reason why we went with magic handlers in the first place.

    If a service has 10 functions, we'll end up deploying the entire service 10 times. Magic handlers allows users to organize their functions and their dependencies in such a way to minimize including code that is not used by the lambda/function. If all functions will have the same code footprint (most of which is not used by that function), then a service is eventually a big fat function.

  13. license2e commented on Jul 6, 2016

    @license2e
    Contributor

    @eahefnawy I agree, with the setup we have and the number of functions we are writing ~1000, we will need those magic handlers. Otherwise, we will have to arbitrarily group certain functions together into a service, and manually keep track of which service has which function.

  14. 29 remaining items

  15. flomotlik commented on Jul 15, 2016

    @flomotlik
    Contributor

    @ac360 we now only create one bucket per service/stage/region combination, but in there we could simply create folders for the different version and put all the files in

  16. austencollins commented on Jul 15, 2016

    @austencollins
    Member

    @flomotlik Right! But, if we add the ability to use a single bucket across multiple services (this feature might have already been added, not sure), keeping the stage in the name will protect us in that case.

  17. flomotlik commented on Jul 17, 2016

    @flomotlik
    Contributor

    @ac360 the most likely option for a single bucket across services is that people manage that bucket themselves imho. I see basically 2 options going forward for the buckets:

    1. We create the bucket for you and name it together with your CF stack. We guarantee naming and that everything works
    2. Users create their own bucket and point us to it (e.g. deployment_bucket setting in their serverless config) so we're going to push to that one

    This might change if we get different feedback from users

  18. doapp-ryanp commented on Jul 19, 2016

    @doapp-ryanp
    Contributor

    Funny how things come full circle :) I'm with @flomotlik 's last comment. Thats exactly how I had it architected in JAWS (could pass S3 bucket to use as CLI opt when creating project).

    Only thing I'd add is when your naming the bucket, please include the region name in it. Ex: uswest2-sls-projName-UUID. As you know when interacting with S3 u need to know what region it is in. Having region name in bucket makes things so much easier to manage when a human needs to get involved.

  19. erikerikson commented on Jul 20, 2016

    @erikerikson
    Contributor

    Yar!

    2 is a must have for us. We appreciated that we would give bucket ${BUCKET} and the artifacts would be placed in ${BUCKET}/Serverless/..., separated as appropriate by region/environment*/et cetera.

    Having region name in bucket makes things so much easier

    By convention, not mandate, yes/please?

    • prefer "environment" (standard industry language) over "stage" (ApiGateway naming artifact)
  20. HyperBrain commented on Jul 20, 2016

    @HyperBrain
    Contributor

    One question: Is the use of aliases and named versions for publishing lambda functions to environments (stages) still an option, instead of naming the lambda functions? For us the number of functions will explode if every environment gets its own function.

    Supporting aliases and versions should be possible with CloudFormation using the AWS:Lambda:Version and AWS:Lambda:Alias CF types. With version even versions with custom names (maybe implied through the user's build system) may be used and the environment ( @erikerikson +1 for the naming ) can be easily attached as alias to that.

  21. eahefnawy commented on Jul 20, 2016

    @eahefnawy
    Contributor

    @HyperBrain its dropped for now. But I see your concern. Does your usecase require handling stages with aliases? or we could just add support for aliases/versions in general and that could work for you?

    The issue with handling stages with aliases/versions that we've found over the months is that not all event sources and other AWS services are aware of this Qualifier or versions/aliases. Didn't sound super reliable.

    Plus, when you deploy to a stage, you gotta navigate to that alias/version, and it confused some people who didnt see their deployment right away.

    @flomotlik any thoughts on this?

  22. HyperBrain commented on Jul 20, 2016

    @HyperBrain
    Contributor

    @eahefnawy Since the latest improvements in the AWS lambda web console, it is far more centric on aliases than on versions. e.g. you now have the prominently placed "Qualifier" selection button in there.

    For us, we heavily depend on the stages/aliases as we use the Qualifier property for our lambda calls.
    Regarding the event sources. In my experience this is the exception. For these few that do not support aliases, the previously used "customName" override was a perfect solution where you could change the semantics quite easily.

  23. eahefnawy commented on Jul 20, 2016

    @eahefnawy
    Contributor

    @HyperBrain Perfectly said 😊 ... let's see what @flomotlik thinks of this.

  24. flomotlik commented on Jul 27, 2016

    @flomotlik
    Contributor

    Yup Alias support is definitely an important one, we do have an issue open, I just can't seem to find it right now :D

  25. pmuens commented on Jul 28, 2016

    @pmuens
    ContributorAuthor

    @flomotlik we have an issue for Lambda versioning here: #1457

  26. removed their assignment
    on Aug 8, 2016
  27. flomotlik commented on Aug 9, 2016

    @flomotlik
    Contributor

    Closing this issue as #1777 is targeting the per function packaging and @johncmckim is going to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions