softprops / serverless-rust

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

Support CI/CD Pipelines using Artifacts #123

Open TravisCalder opened 9 months ago

TravisCalder commented 9 months ago

💡 Feature description

When an artifact is provided in serverless.yaml for a Rust function, skip building that function and use the provided artifact instead.

This should not cause the error for no Rust functions found to trigger, even if all Rust functions are skipped this way.

This is required to support CI/CD pipeline patterns where artifacts are built in one step, then verified, and then the verified artifact is deployed without recompiling which could introduce variance.

Nice To Have:

It would also be nice if the "no Rust functions" error could be suppressed, and if Rust functions could be discovered in a way that doesn't cause schema warnings.

💻 Basic example

For the following serverless.yaml:

service: barebones-service
provider:
  name: aws
  runtime: rust
  memorySize: 128
  stage: dev

package:
  individually: true

custom:
  rust:
    dockerless: true

plugins:
  - serverless-rust

functions:
  restApi:
    handler: "rest"
    events:
      - httpApi: '*'
    package:
      artifact: ${param:artifact,""}

This allows a build-and-deploy workflow:

serverless deploy --stage stage

Or an artifact workflow:

serverless package --stage stage
cp target/lambda/release/rest.zip artifacts/
# VERIFY PACKAGE
serverless deploy --stage stage --param="artifact=artifacts/rest.zip"