feat(cli-internal): add lambda layer support to gen2-migration generate command#14780
Open
adrianjoshua-strutt wants to merge 2 commits intogen2-migrationfrom
Open
feat(cli-internal): add lambda layer support to gen2-migration generate command#14780adrianjoshua-strutt wants to merge 2 commits intogen2-migrationfrom
adrianjoshua-strutt wants to merge 2 commits intogen2-migrationfrom
Conversation
…te command The gen2-migration generate command now reads Lambda layer configurations from deployed functions and generates the corresponding `layers` property in `defineFunction()` calls. Previously, layers were silently dropped during migration, requiring users to manually recreate layer configurations in Gen2. Now layer ARNs are extracted from the AWS SDK response and mapped into Gen2's native `layers` format using the layer name from the ARN as the key. Changes: - Added `layers` to ResolvedFunction and RenderDefineFunctionOptions interfaces - Added extractLayers() with ARN validation and duplicate detection - Added renderLayers() to emit layers in the defineFunction() AST - Updated LambdaMock to return layer data from CFN templates - Updated project-boards test fixtures with layer configurations - Added 9 unit tests for extractLayers() edge cases All 28 tests pass (12 snapshot + 16 unit). Closes #14527 --- Prompt: Implement Lambda layers support in the gen2-migration generate command. The generate command should read layer configurations from Gen1 functions and generate the appropriate Gen2 defineFunction() layers property.
Update GEN2_MIGRATION_GUIDE.md feature coverage matrix to reflect that Lambda layers attached to functions are now handled by the generate step. Changed from 🔴 (unsupported) to 🟡 (generate ✔, refactor ✗). Standalone Lambda layer resources (function:LambdaLayer in amplify-meta.json) remain unsupported. --- Prompt: Update docs for the Lambda layers feature in gen2-migration generate command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
The
gen2-migration generatecommand now handles Lambda layersattached to functions. Previously, layer configurations were silently
dropped during migration — users had to manually recreate them in
Gen2 after running the tool.
The generate command already fetches
FunctionConfigurationfrom theAWS SDK (which includes
Layers), but the field was never read. ThisPR reads the layer data from the deployed function config and
generates Gen2's native
defineFunction({ layers })property.Key design decision: The AWS SDK returns layer ARNs but not the
module names that layers export. Gen2's
layersrecord uses modulenames as keys (for bundler externalization). Since the actual module
name isn't available from the API, we extract the layer name from the
ARN and use it as the key. Users may need to update the key to match
their actual import path after migration.
Core logic
FunctionGenerator.resolve()now callsextractLayers()to parsethe
config.Layersarray into aRecord<string, string>. The layername is extracted from the ARN (segment 6 in the colon-delimited
format).
FunctionRenderer.renderLayers()emits the record as anAST object literal in the
defineFunction()call, following the samepattern used for
environment.extractLayers()validates ARN structure (minimum 8 segments,resource type must be
layer) and throws on duplicate layer nameswith a descriptive error message.
Test fixtures
Updated the
project-boardstest app to include two Lambda layerson the
quotegeneratorfunction. Updated theLambdaMockto readLayersfrom CFN templates and return them in theGetFunctionCommandresponse.Documentation
Updated
GEN2_MIGRATION_GUIDE.mdto change Lambda layer supportfrom 🔴 (unsupported) to 🟡 (generate ✔, refactor ✗).
Issue #, if available
Closes #14527
Description of how you validated changes
updated
project-boardssnapshot with layers in the expecteddefineFunction()outputextractLayers()covering: undefined input,empty array, missing ARNs, malformed ARNs, non-layer ARNs,
duplicate layer names, 5-layer maximum, and the happy path
git-secrets)
Checklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.