Fine-grained hot reloading configuration for functions and layers to replace global `mountCode` option
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript
- Bereich
- tooling
Rechercherichtung
Beginne mit der Prüfung von PR #222 und der vorhandenen custom.localstack.lambda.mountCode-Konfiguration. Vergleiche anschließend die vorgeschlagenen hotReload-Eigenschaften auf Funktions- und Layer-Ebene mit der verlinkten Serverless-Konfiguration und der Dokumentation zur Schemaerweiterung. Erledigt ist die Aufgabe, wenn die vier aufgeführten User Stories unterstützt werden, das Verhalten für Layer definiert ist und der Ersatz für die veraltete globale Option dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- https://github.com/localstack/serverless-localstack/pull/222
- https://github.com/localstack/serverless-localstack/issues/129
- https://github.com/localstack/serverless-localstack/issues/216
Challenges
mountCode: trueis 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
mountCodeis 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/).hotReloadwould 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: trueuses 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
- Serverless documentation on how to provide custom plugin configuration options: https://www.serverless.com/framework/docs/guides/plugins/custom-configuration
- It is possible to add custom function-level properties using "Function properties via defineFunctionProperties" via defineFunctionProperties
- There is no well-defined mechanism to add layer-level properties. It might be possible to do manually using
addPropertiesToSchemato add something likedefineLayerProperties?! Might need to relax provider schema by allowing additional properties like for functions.patternProperties here https://github.com/serverless/serverless/blob/ed15cb27aee68954c93d875da96274914943ad71/lib/classes/config-schema-handler/index.js#L335 - There is some API to extend configuration: https://www.serverless.com/framework/docs/guides/plugins/extending-configuration
- There is no well-defined mechanism to add layer-level properties. It might be possible to do manually using
- Serverless v3 comes with breaking changes regarding plugin variable resolving (e.g., comes with stricter validation): https://www.serverless.com/framework/docs/guides/upgrading-v3#new-variable-resolver-engine
User Stories
Enable hot reloading for:
- Single function code
- Single function code + single layer
- Single layer
- 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
- Hot reloading for layers is configured per layer (rather than per layer usage) and applies to all functions using the layer
- 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.
- 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
- Creating python-requirements layer
- Using an existing layer from another function in the same region
- Non-requirements/ generic layers (example: https://www.serverless.com/blog/publish-aws-lambda-layers-serverless-framework)
- Vorherrschende Sprache
- JavaScript
- Sterne
- 542
- Forks
- 92
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus localstack/serverless-localstack
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 25/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 42/100
-
aws:apigateway status: backlog
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
localstack/serverless-localstack#270 · 3 Reaktionen ·
Alle Issues in localstack/serverless-localstack
Ähnliche Issues
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
vercel/ai#21528 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
status: waiting triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
freeCodeCamp/freeCodeCamp#70412 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
rohitg00/ai-engineering-from-scratch#490 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 6 Tagen