softprops / serverless-rust

⚡ 🦀 a serverless framework plugin for rustlang applications
https://www.npmjs.com/package/serverless-rust
MIT License
548 stars 82 forks source link

feat: support builds from a cargo workspace #118

Open JoelRoxell opened 2 years ago

JoelRoxell commented 2 years ago

What did you implement:

Adds a new custom flag to signal that the serverless.yml is nested in a cargo workspace. Since the binaries will be outputted to a target folder in the workspace root, the zip-copy-process needs to take that into account.

Not sure if this is the most appropriate change; however, it solved my problem.

I want to be able to separate the lambda-projects to isolate different dependencies etc.

custom:
  rust:
    dockerless: true
    inWorkspace: true # <---- Defaults to false

How did you verify your change:

Deployed multiple stacks from the workspace root to AWS using serverless components.

.
├── Cargo.lock
├── Cargo.toml
├── shared-infra
│   └── serverless.yml
├── package.json
├── package-lock.json
├── lambda1 # rest api
│   ├── Cargo.toml
│   ├── serverless.yml
│   ├── src
│   │   ├── handler.rs
│   │   └── main.rs
│   └── target
│       └── lambda
│           └── release
│               └── lambda1.zip
├── lambda2 # queue-consumer
│   ├── Cargo.toml
│   ├── serverless.yml
│   ├── src
│   │   ├── handler.rs
│   │   ├── main.rs
│   │   └── messages.rs
│   └── target
│       └── lambda
│           └── release
│               └── lambda2.zip
├── serverless-compose.yml
├── target
│   ├── release
│   └── x86_64-unknown-linux-musl
│       └── release
│           ├── lambda1
│           ├── lambda1.d
│           ├── lambda2
│           └── lambda2.d
└── yarn.lock