(aws-lambda): fromDockerBuild output is located incorrectly
See original GitHub issueIn v1.92.0
, when fromDockerBuild
is used, it is expected that contents /asset
is copied, but instead the whole /asset
is copied to output path, this makes Lambda handler reference index.handler
failed, it has to be asset/index.handler
.
Reproduction Steps
Create a index.js.
exports.handler = () => {
console.info("Test");
}
A Dockerfile:
FROM amazon/aws-sam-cli-build-image-nodejs14.x
COPY index.js /asset/
Use lambda.Code.fromDockerBuild
:
export class ExampleStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new lambda.Function(this, "ExampleFunction", {
runtime: lambda.Runtime.NODEJS_14_X,
handler: "index.handler",
code: lambda.Code.fromDockerBuild(ROOT_DIR),
});
}
}
What did you expect to happen?
The Lamda code contains only index.js
.
What actually happened?
The Lambda code contains asset/index.js
.
Environment
- CDK CLI Version : 1.92.0
- Framework Version: 1.92.0
- Node.js Version: 14
- OS : macOS Catalina
- Language (Version): TypeScript 4.2.3
Other
This is caused by expected behavior of docker cp
.
Suggestion: automatically append /.
to imagePath
if it doesn’t.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Troubleshoot container image issues in Lambda
Verify that the ENTRYPOINT to your container image includes the absolute path as the location. Also verify that the image does not contain...
Read more >Creating Lambda container images - AWS Documentation
Create a container image for a Lambda function by using an AWS provided base image or an alternative base image.
Read more >Troubleshoot deployment issues in Lambda
This issue can occur when you specify an Amazon S3 object in a call to UpdateFunctionCode, or use the package and deploy commands...
Read more >Testing Lambda container images locally - AWS Documentation
Test the container image for your AWS Lambda function locally using the runtime interface ... Build your image locally using the docker build...
Read more >Troubleshooting errors with Docker commands when using ...
You can work around this bug by removing the https:// scheme from the registry argument in the Docker login command that is output...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@phuctm97 are you taking this? I see a commit on your fork that references this issue.
I was thinking that something like this would do it:
I would personally not change the
cp()
method incore
, I think it must remain general purpose.(cc @eladb)
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.