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)
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.
@annguyen36 Thanks for filing this. I am working on a similar problem. I think the issue need to be labeled as bug and triage to be visible in the queue.
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 ofDockerLayerStack
'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 theDockerImageFunction
construct, as well as theaddLayer()
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