0

sam build copies whole project folder instead of lambda function folder(s).

I have this project structure:

.
├── aws.yaml
├── package.json
├── package-lock.json
└── src
    ├── postAuthentication
    │   └── main.js
    └── postConfirmation
        └── main.js

My sam (cloudformation) template looks like this (abbreviated):

LambdaPostAuthentication:
  Type: AWS::Serverless::Function
  Properties:
    Runtime: nodejs12.x
    CodeUri: ./src/postAuthentication
    Handler: ./src/postAuthentication/main.handler

LambdaPostConfirmation:
  Type: AWS::Serverless::Function
  Properties:
    Runtime: nodejs12.x
    CodeUri: ./src/postConfirmation
    Handler: ./src/postConfirmation/main.handler

sam build gives me:

.
└── build
    ├── LambdaPostAuthentication
    │   ├── package.json
    │   ├── node_modules
    │   └── src
    │       ├── postAuthentication
    │       │   └── main.js
    │       └── postConfirmation
    │           └── main.js
    ├── LambdaPostConfirmation
    │   ├── package.json
    │   ├── node_modules
    │   └── src
    │       ├── postAuthentication
    │       │   └── main.js
    │       └── postConfirmation
    │           └── main.js
    └── template.yaml

What I expect to get is the following:

.
└── build
    ├── LambdaPostAuthentication
    │   ├── package.json
    │   ├── node_modules
    │   └── src
    │       └── postAuthentication
    │           └── main.js

    ├── LambdaPostConfirmation
    │   ├── package.json
    │   ├── node_modules
    │   └── src
    │       └── postConfirmation
    │           └── main.js
    └── template.yaml

I also tried absolute paths for CodeUri and Handler but to no avail.

MarMun
  • 91
  • 7

1 Answers1

0

Make sure both ./src/postAuthentication and ./src/postConfirmation have a package.json file in them.

Steven Linn
  • 696
  • 5
  • 14