Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda: two lambda.Code.fromDockerBuild() in same stack resolve to same hash artifact #30528

Closed
refacktor opened this issue Jun 12, 2024 · 2 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@refacktor
Copy link

Describe the bug

my stack has two different lambda.Code.fromDockerBuild():

    const func = new lambda.Function(this, 'IngestFunction', {
        runtime: lambda.Runtime.PROVIDED_AL2023,
        handler: 'bootstrap',
        functionName: 'rets-efs-ingest',
        code: lambda.Code.fromDockerBuild(path.join(__dirname, '..', 'lambda_ingest'), {
            file: 'Dockerfile',
            imagePath: '/build/bin/',
            outputPath: '/var/task',
        }),

... and ...

    const queryFunc = new lambda.Function(this, 'QueryFunction', {
        runtime: lambda.Runtime.PROVIDED_AL2023,
        handler: 'bootstrap',
        functionName: 'rets-efs-query',
        code: lambda.Code.fromDockerBuild(path.join(__dirname, '..', 'lambda_query'), {
            file: 'Dockerfile.query',
            imagePath: '/asset',
            outputPath: '/var/task',
        }),

Expected Behavior

The Dockerfile for each function should independently get built and the artifact deployed

Current Behavior

The artifact for the first function gets built and then gets deployed twice, for both functions.
i.e. incorrect artifact is deployed for the second function

While inspecting the cdk.out folder it's easy to see that only one artifact is built

Reproduction Steps

cdk deploy

Possible Solution

Not a fix, but as a workaround perhaps you could allow assetHash to be overridden

Additional Information/Context

both lambdas are in the same stack. the imagePath in the example is different in each file due to troubleshooting steps already taken. Making it a different value did not change the hash

CDK CLI Version

2.134.0

Framework Version

No response

Node.js Version

18.19.1

OS

Windows 10

Language

TypeScript

Language Version

No response

Other information

No response

@refacktor refacktor added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 12, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jun 12, 2024
@refacktor
Copy link
Author

Work-around found: use a different value for outputPath in each Lambda.

Copy link

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant