Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Serverless deploy pipe is not packaging service according to include/excludes

Alejandro Torroella
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2021

I have two serverless.yml for two different services, my project structure is as below:

  • src
    • auth
      • handle.js
      • serverless.yml
    • service
      • index.js
  • serverless.yml

 

my bitbucket-pipeline.yml looks something like this:

pipelines:
branches:
master:
-
step:
name: Deploy Authorizer
caches:
-
node
script:
-
pipe: atlassian/serverless-deploy:0.2.2
variables:
CONFIG: "./src/auth/serverless.yml"
[AWS_CREDS]


-
step:
name: Deploy to Production
deployment: production
caches:
-
node
script:
-
npm install
-
pipe: atlassian/serverless-deploy:0.2.2
variables:
 [AWS_CREDS]

 

My auth/serverless.yml has this in it:

package:
include:
- handler.js

 

My service and auth lambdas get deployed successfully, but the zipped package for my auth lambda includes my entire project, even with the package/include specifying that I only want that one handler.js file included.

 

This causes issues when the lambda is deployed since the serverless.yml specifies the handler path relative to the serverless.yml, but once it's in AWS with all the extra project files, the relative path breaks and it can't execute the code in handler.js

 

Right now, this seems like a bug because when just doing a:

serverless package

in my auth directory, the handler.js is correctly the only file that's in the zipped package. But through the bitbucket pipe, it ignores the include option and shoves everything in there.

1 answer

0 votes
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 30, 2021

@Alejandro Torroella I suspect it includes your entire project because you're located not in auth directory before executing pipe, but in the root.

So by default, serverless packages your entire project.

Based on this I can propose you either change directory by cd-in to the right directory before pipe execution or do not package if that satisfy your requirements and deploy from a directory (See subscection `Deployment from a pre-packaged directory` https://www.serverless.com/framework/docs/providers/aws/cli-reference/deploy/).

We are looking forward to hearing from you, if that would work for you, otherwise we will try to reproduce and find the answer together or to make some change to make it more adaptable.

Regards, Galyna

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events