Deploying multiple AWS lambdas separately










1















I'm using Serverless Framework 1.32.0 with AWS Lambdas and Python 3.6. I would like to deploy multiple lambdas in a separate way, since at this moment I can only do deployments one by one for every lambda in my directory, which can be confusing with many lambdas in a short future.



This is my current project structure:



└── cat_service
│  
├── hello_cat
│   ├── hello_cat-functions.yml
│   └── service.py
│  
├── random_cat_fact
│   ├── random_cat_fact-functions.yml
│   └── service.py
│  
└── serverless.yml


serverless.yml



service: cat-service 

provider:
name: aws
runtime: python3.6
stage: dev
stackName: cat-service
deploymentBucket:
name: test-cat-bucket
role: arn:aws:iam::#AWS::AccountId:role/lambda-cat-role
cfnRole: arn:aws:iam::#AWS::AccountId:role/cloudformation-cat-role

functions:
- $file(lambdas/hello_cat/hello_cat-functions.yml)

stepFunctions:
stateMachines:
catStateMachine:
definition:
Comment: "Get cat hello"
StartAt: hello_cat
States:
hello_cat:
Type: Task
Resource: "arn:aws:lambda:#AWS::Region:#AWS::AccountId:function:$self:service-$opt:stage-hello_cat"
End: true

plugins:
- serverless-step-functions
- serverless-pseudo-parameters


hello_cat-functions.yml



msc_cat_facts:
handler: service.handler
name: $self:service-$opt:stage-msc_cat_facts


The problem is that, when I deploy it with serverless deploy --stage dev, it zips the full project and does not separate lambdas, so the actual Lambda in the AWS console shows as hello_cat but includes the full project structure instead of separating every lambda files in its own directory.



Is there a way to deploy separate lambdas in the same project with only one serverless.yml?



Thanks in advance.










share|improve this question


























    1















    I'm using Serverless Framework 1.32.0 with AWS Lambdas and Python 3.6. I would like to deploy multiple lambdas in a separate way, since at this moment I can only do deployments one by one for every lambda in my directory, which can be confusing with many lambdas in a short future.



    This is my current project structure:



    └── cat_service
    │  
    ├── hello_cat
    │   ├── hello_cat-functions.yml
    │   └── service.py
    │  
    ├── random_cat_fact
    │   ├── random_cat_fact-functions.yml
    │   └── service.py
    │  
    └── serverless.yml


    serverless.yml



    service: cat-service 

    provider:
    name: aws
    runtime: python3.6
    stage: dev
    stackName: cat-service
    deploymentBucket:
    name: test-cat-bucket
    role: arn:aws:iam::#AWS::AccountId:role/lambda-cat-role
    cfnRole: arn:aws:iam::#AWS::AccountId:role/cloudformation-cat-role

    functions:
    - $file(lambdas/hello_cat/hello_cat-functions.yml)

    stepFunctions:
    stateMachines:
    catStateMachine:
    definition:
    Comment: "Get cat hello"
    StartAt: hello_cat
    States:
    hello_cat:
    Type: Task
    Resource: "arn:aws:lambda:#AWS::Region:#AWS::AccountId:function:$self:service-$opt:stage-hello_cat"
    End: true

    plugins:
    - serverless-step-functions
    - serverless-pseudo-parameters


    hello_cat-functions.yml



    msc_cat_facts:
    handler: service.handler
    name: $self:service-$opt:stage-msc_cat_facts


    The problem is that, when I deploy it with serverless deploy --stage dev, it zips the full project and does not separate lambdas, so the actual Lambda in the AWS console shows as hello_cat but includes the full project structure instead of separating every lambda files in its own directory.



    Is there a way to deploy separate lambdas in the same project with only one serverless.yml?



    Thanks in advance.










    share|improve this question
























      1












      1








      1








      I'm using Serverless Framework 1.32.0 with AWS Lambdas and Python 3.6. I would like to deploy multiple lambdas in a separate way, since at this moment I can only do deployments one by one for every lambda in my directory, which can be confusing with many lambdas in a short future.



      This is my current project structure:



      └── cat_service
      │  
      ├── hello_cat
      │   ├── hello_cat-functions.yml
      │   └── service.py
      │  
      ├── random_cat_fact
      │   ├── random_cat_fact-functions.yml
      │   └── service.py
      │  
      └── serverless.yml


      serverless.yml



      service: cat-service 

      provider:
      name: aws
      runtime: python3.6
      stage: dev
      stackName: cat-service
      deploymentBucket:
      name: test-cat-bucket
      role: arn:aws:iam::#AWS::AccountId:role/lambda-cat-role
      cfnRole: arn:aws:iam::#AWS::AccountId:role/cloudformation-cat-role

      functions:
      - $file(lambdas/hello_cat/hello_cat-functions.yml)

      stepFunctions:
      stateMachines:
      catStateMachine:
      definition:
      Comment: "Get cat hello"
      StartAt: hello_cat
      States:
      hello_cat:
      Type: Task
      Resource: "arn:aws:lambda:#AWS::Region:#AWS::AccountId:function:$self:service-$opt:stage-hello_cat"
      End: true

      plugins:
      - serverless-step-functions
      - serverless-pseudo-parameters


      hello_cat-functions.yml



      msc_cat_facts:
      handler: service.handler
      name: $self:service-$opt:stage-msc_cat_facts


      The problem is that, when I deploy it with serverless deploy --stage dev, it zips the full project and does not separate lambdas, so the actual Lambda in the AWS console shows as hello_cat but includes the full project structure instead of separating every lambda files in its own directory.



      Is there a way to deploy separate lambdas in the same project with only one serverless.yml?



      Thanks in advance.










      share|improve this question














      I'm using Serverless Framework 1.32.0 with AWS Lambdas and Python 3.6. I would like to deploy multiple lambdas in a separate way, since at this moment I can only do deployments one by one for every lambda in my directory, which can be confusing with many lambdas in a short future.



      This is my current project structure:



      └── cat_service
      │  
      ├── hello_cat
      │   ├── hello_cat-functions.yml
      │   └── service.py
      │  
      ├── random_cat_fact
      │   ├── random_cat_fact-functions.yml
      │   └── service.py
      │  
      └── serverless.yml


      serverless.yml



      service: cat-service 

      provider:
      name: aws
      runtime: python3.6
      stage: dev
      stackName: cat-service
      deploymentBucket:
      name: test-cat-bucket
      role: arn:aws:iam::#AWS::AccountId:role/lambda-cat-role
      cfnRole: arn:aws:iam::#AWS::AccountId:role/cloudformation-cat-role

      functions:
      - $file(lambdas/hello_cat/hello_cat-functions.yml)

      stepFunctions:
      stateMachines:
      catStateMachine:
      definition:
      Comment: "Get cat hello"
      StartAt: hello_cat
      States:
      hello_cat:
      Type: Task
      Resource: "arn:aws:lambda:#AWS::Region:#AWS::AccountId:function:$self:service-$opt:stage-hello_cat"
      End: true

      plugins:
      - serverless-step-functions
      - serverless-pseudo-parameters


      hello_cat-functions.yml



      msc_cat_facts:
      handler: service.handler
      name: $self:service-$opt:stage-msc_cat_facts


      The problem is that, when I deploy it with serverless deploy --stage dev, it zips the full project and does not separate lambdas, so the actual Lambda in the AWS console shows as hello_cat but includes the full project structure instead of separating every lambda files in its own directory.



      Is there a way to deploy separate lambdas in the same project with only one serverless.yml?



      Thanks in advance.







      python-3.x amazon-web-services aws-lambda serverless-framework aws-step-functions






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 5:51









      CarlosCarlos

      649




      649






















          1 Answer
          1






          active

          oldest

          votes


















          2














          You'll need to configure Serverless to package individually



          To do this add the following to your serverless.yaml:



          package:
          individually: true





          share|improve this answer























          • Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

            – Carlos
            Nov 13 '18 at 20:45










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274624%2fdeploying-multiple-aws-lambdas-separately%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You'll need to configure Serverless to package individually



          To do this add the following to your serverless.yaml:



          package:
          individually: true





          share|improve this answer























          • Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

            – Carlos
            Nov 13 '18 at 20:45















          2














          You'll need to configure Serverless to package individually



          To do this add the following to your serverless.yaml:



          package:
          individually: true





          share|improve this answer























          • Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

            – Carlos
            Nov 13 '18 at 20:45













          2












          2








          2







          You'll need to configure Serverless to package individually



          To do this add the following to your serverless.yaml:



          package:
          individually: true





          share|improve this answer













          You'll need to configure Serverless to package individually



          To do this add the following to your serverless.yaml:



          package:
          individually: true






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 8:58









          thomasmichaelwallacethomasmichaelwallace

          2,5451817




          2,5451817












          • Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

            – Carlos
            Nov 13 '18 at 20:45

















          • Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

            – Carlos
            Nov 13 '18 at 20:45
















          Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

          – Carlos
          Nov 13 '18 at 20:45





          Thanks for your response. I tried that approach but didn't work, for some reason creates a main lambda with the two others inside of it, instead of separating them. My implementation was as mentioned in forum.serverless.com/t/…

          – Carlos
          Nov 13 '18 at 20:45

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274624%2fdeploying-multiple-aws-lambdas-separately%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          What does pagestruct do in Eviews?

          Dutch intervention in Lombok and Karangasem

          Channel Islands