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-go-alpha: CDK Stages don't work properly on their own #26358

Open
KamWithK opened this issue Jul 14, 2023 · 10 comments
Open

lambda-go-alpha: CDK Stages don't work properly on their own #26358

KamWithK opened this issue Jul 14, 2023 · 10 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda @aws-cdk/aws-lambda-go bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@KamWithK
Copy link

Describe the bug

I've been using the TypeScript CDK with AWS CodePipelines and Golang lambda functions for a short while
Recently I tried to create some quick tests, and so tried to deploy a simple cutdown CDK Stage instead of a full pipeline deployment
However, there seems to be a bug where the CDK won't deploy any lambda function binaries during the first deployment (instead it just uploads the source code, which obviously can't work)

Expected Behavior

Deploy the binary

Current Behavior

Instead of the binary getting deployed, most of the time the source code folder just gets deployed

Reproduction Steps

I've created a simple minimal example to illustrate the problem more clearly:
https://github.com/KamWithK/golang_stage_aws_test

Possible Solution

No idea why this happens, or whether something I'm doing is causing it, but it seems quite sporadic
Very very rarely it won't happen and the binary will be deployed correctly
Normally if the source code gets deployed instead of the binary, rerunning the synth command and then deploying will cause the binary to replace the source code
This stuff seems to happen somewhat randomly though so I'm not sure why

Additional Information/Context

I'm trying to use a stage by itself purely because local testing frameworks don't support AWS features like pipelines, the problem occurs on AWS itself though

CDK CLI Version

2.87.0 (build 9fca790)

Framework Version

No response

Node.js Version

18.16.1

OS

Windows 11

Language

Typescript

Language Version

No response

Other information

I was debating whether to create an issue here or on the AWS lambda go repository
I've posted here for now because I don't know how to verify whether the problem is with their library or the CDK doing something funky which could maybe be more than just the lambda (just a worry, not sure how to test/verify that)

@KamWithK KamWithK added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 14, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jul 14, 2023
@pahud pahud changed the title Stage: CDK Stages don't work properly on their own aws-lambda-go-alpha: CDK Stages don't work properly on their own Jul 14, 2023
@pahud pahud changed the title aws-lambda-go-alpha: CDK Stages don't work properly on their own lambda-go-alpha: CDK Stages don't work properly on their own Jul 14, 2023
@pahud
Copy link
Contributor

pahud commented Jul 14, 2023

Looks like the entry in your code is incorrect:

https://github.com/KamWithK/golang_stage_aws_test/blob/3d8ab6ddde8d269ca4692cd6d1352ffd36d078f2/infrastructure/lib/test-stack.ts#L10

I would rather use path like this

import { GoFunction } from '@aws-cdk/aws-lambda-go-alpha';
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as path from 'path';

export class TestStack extends Stack {
    constructor(scope: Construct, id: string, props?: StackProps) {
        super(scope, id, props);

        new GoFunction(this, 'testFunction', {
            entry: path.join(__dirname, '../../functions/test'),
            functionName: 'testFunction',
        });
    }
}

@pahud pahud added p2 effort/medium Medium work item – several days of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 14, 2023
@KamWithK
Copy link
Author

I gave that a try but nothing has changed
Makes sense since I believe this is just a slightly different way to express the path

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 15, 2023
@KamWithK
Copy link
Author

KamWithK commented Aug 1, 2023

Any updates or suggestions?

@KamWithK
Copy link
Author

KamWithK commented Aug 1, 2023

@pahud what'd you think?

@pahud
Copy link
Contributor

pahud commented Aug 1, 2023

I was able to synth and deploy your sample:

gitpod /workspace/golang_stage_aws_test/infrastructure ((3d8ab6d...)) $ npx cdk synth
Bundling asset testStage/testStack/testFunction/Code/Stage...
Successfully synthesized to /workspace/golang_stage_aws_test/infrastructure/cdk.out
Supply a stack id () to display its template.

And when I click the Test button from the lambda console I can see it successfully returned "Test"

image

This seems working pretty well for me.

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 1, 2023
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Aug 3, 2023
@KamWithK
Copy link
Author

KamWithK commented Aug 5, 2023

I was able to synth and deploy your sample:

gitpod /workspace/golang_stage_aws_test/infrastructure ((3d8ab6d...)) $ npx cdk synth
Bundling asset testStage/testStack/testFunction/Code/Stage...
Successfully synthesized to /workspace/golang_stage_aws_test/infrastructure/cdk.out
Supply a stack id () to display its template.

And when I click the Test button from the lambda console I can see it successfully returned "Test"
image

This seems working pretty well for me.

It sometimes does and sometimes doesn't work
The first time I tried to deploy it to AWS it failed for me for example
Usually resynth and redeploy will fix the problem and get it to deploy the actual binaries

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Aug 5, 2023
@pahud
Copy link
Contributor

pahud commented Aug 16, 2023

I am not sure if this is related to the Windows 11 environment but it always works for me when I open your repo with GitPod. Are you able to test that in any other environment and see if it still fails?

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 16, 2023
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Aug 18, 2023
@KamWithK
Copy link
Author

I am not sure if this is related to the Windows 11 environment but it always works for me when I open your repo with GitPod. Are you able to test that in any other environment and see if it still fails?

I'll try and see whether deploying into a different environment soon then
What about my environment could cause something like this to happen though?

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Aug 19, 2023
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 @aws-cdk/aws-lambda-go bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants