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.
You'll need to configure Serverless to package individually
To do this add the following to your serverless.yaml:
package:
individually: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With