(@aws-cdk/aws-lambda): layers property and addLayer() DockerLayerStack construct
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
Hello team,
Main issue: Lambda functions packaged as container images do not support adding Lambda layers to the function configuration, but CDK docs lists `layers` property as one of `DockerLayerStack`'s valid props and addLayer() is valid method.
From this closed issue: https://github.com/aws/aws-cdk/issues/14143
although there is an error added to the synthesis step when creating container function with layers, I found the issue with addLayer() method when trying to add the layer to the container function, it was passed the synthesize step and failed at stack deployment:
❌ Deployment failed: Error: The stack named DockerLayerStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Please don't provide Handler or Runtime or Layer when the intended function PackageType is Image. (Service: Lambda, Status Code: 400)" HandlerErrorCode: InvalidRequest)
## What did you expect to have ##
doc: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.DockerImageFunction.html#addwbrlayerslayers
If the `layers` property is not able to used to add layer to the `DockerImageFunction` construct, as well as the `addLayer()` method as this is something Lambda not support, I'm expecting these 2 are not listed in CDK documentation.
This creates a lot of confusion, please consider to revise this doc.
_Originally posted by @annguyen36 in https://github.com/aws/aws-cdk/issues/14143#issuecomment-1771802154_
Contributor guide
Research direction
Start with the AWS CDK API documentation entry for DockerImageFunction.addLayers and the referenced closed issue #14143, then verify how the layers property and addLayer() are presented for container-image functions. Done means the documentation no longer presents unsupported layer configuration as valid for DockerImageFunction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100