localstack / localstack/serverless-localstack

Fine-grained hot reloading configuration for functions and layers to replace global `mountCode` option

Đang mở
#223 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement status: backlog
Ngôn ngữ chính
JavaScript
Star
542
Fork
92
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The current hot reloading configuration mountCode has many limitations (e.g., global config, no layer support). An improved configuration API and documentation could make hot reloading more powerful and easier to use with the Serverless Framework.

Related Issues/PRs

Challenges

  • mountCode: true is a global option but currently does not support hot-reloading of layers (new feature in LocalStack 2.0).
  • Hot reloading (currently) only works with at most one layer per function. Hence, if we intend to apply mountCode to layers as well, it fails if there is any function with more than one layer in the serverless.yml
  • mountCode is bad terminology because the current implementation does not do any mounting anymore but rather copies ZIP files (https://docs.localstack.cloud/user-guide/tools/lambda-tools/hot-reloading/). hotReload would be a better name
  • We need to consider the scope of hot reloading because not everyone wants to enable hot reloading globally. Selectively enabling hot reloading for single functions or layers under development would be helpful.
  • mountCode: true uses the current directory (assumed to be project directory) as default hot reload path or accepts relative paths (e.g., ./functions). This might lead to many unnecessary and slow reloads.

Background

User Stories

Enable hot reloading for:

  1. Single function code
  2. Single function code + single layer
  3. Single layer
  4. Two functions sharing the same hot-reloaded layer

These cases are supported by LocalStack but not by the serverless-localstack plugin.

Possible API

service: myService

plugins:
  - serverless-localstack

custom:
  localstack:
# DEPRECATED global config
#    lambda:
#      mountCode: true
    stages:
      - local
    host: http://127.0.0.1

provider:
  name: aws
  region: us-east-1
  runtime: python3.9
  # OPTIONAL provider-scoped config here (would need to think about function vs. layers scope)

# https://www.serverless.com/framework/docs/providers/aws/guide/layers
layers:
  layerOne:
    path: layerOne
    hotReload: true

# https://www.serverless.com/framework/docs/providers/aws/guide/functions
functions:
  hello:
    handler: handler.handler
    hotReload: true
    layers:
      - !Ref LayerOneLambdaLayer
Considerations
  1. Hot reloading for layers is configured per layer (rather than per layer usage) and applies to all functions using the layer
  2. LocalStack (currently) support at most one layer in total when using hot reloading for a layer. This makes it difficult to apply hot reloading globally for layers.
  3. Should we consider supporting ZIP files for hot reloading such that we can re-use build steps from tools such as Serverless, Gradle, etc rather than adding extra steps to unzip these archives (Java Gradle example).
Alternatives to create layers with Serverless

Based on https://www.tutorialspoint.com/serverless/serverless_layer_creation.htm

  1. Creating python-requirements layer
  2. Using an existing layer from another function in the same region
  3. Non-requirements/ generic layers (example: https://www.serverless.com/blog/publish-aws-lambda-layers-serverless-framework)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng việc xem xét PR #222 liên quan và cấu hình custom.localstack.lambda.mountCode hiện có, sau đó so sánh các thuộc tính hotReload được đề xuất ở cấp function và layer với cấu hình Serverless được liên kết và tài liệu mở rộng schema. Công việc được xem là hoàn tất khi bốn user story được liệt kê đều được hỗ trợ, hành vi của layer được xác định và phần thay thế cho tùy chọn toàn cục đã lỗi thời được ghi lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.