aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.52k stars 3.86k forks source link

aws-cdk-lib: lambda runtime NodeJS_20_X with AWSParametersAndSecretsLambdaExtension erroring status 127 #29038

Closed juwara0 closed 3 months ago

juwara0 commented 7 months ago

Describe the bug

A Lambda that is working successfully with Runtime.NODEJS_18_X that when updated to Runtime.NODEJS_20_X is now failing with this error in CloudWatch: INIT_START Runtime Version: nodejs:20.v15 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:0856f5d760b75612d4aa6b5feda50bafc1ce3ba07c036cbd0abc585dc28fb870

[AWS Parameters and Secrets Lambda Extension] 2024/02/08 19:39:40 PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL is error. Log level set to error.

EXTENSION Name: AWSParametersAndSecretsLambdaExtension State: Ready Events: [INVOKE, SHUTDOWN]

INIT_REPORT Init Duration: 77.30 ms Phase: init Status: error Error Type: Runtime.ExitError

RequestId: 89fcebe3-f830-4861-8686-f4e7f3c31114 Error: Runtime exited with error: exit status 127 Runtime.ExitError

Expected Behavior

Updating the runtime of the Lambda should not cause this error.

Current Behavior

INIT_START Runtime Version: nodejs:20.v15 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:0856f5d760b75612d4aa6b5feda50bafc1ce3ba07c036cbd0abc585dc28fb870

[AWS Parameters and Secrets Lambda Extension] 2024/02/08 19:39:40 PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL is error. Log level set to error.

EXTENSION Name: AWSParametersAndSecretsLambdaExtension State: Ready Events: [INVOKE, SHUTDOWN]

INIT_REPORT Init Duration: 77.30 ms Phase: init Status: error Error Type: Runtime.ExitError

Reproduction Steps

const paramsAndSecrets = ParamsAndSecretsLayerVersion.fromVersion( ParamsAndSecretsVersions.V1_0_103, { cacheSize: 500, logLevel: ParamsAndSecretsLogLevel.ERROR, } );

const lambdaFunction = new NodejsFunction(
  this,
  'Lambda',
  {
    runtime: Runtime.NODEJS_20_X,
    entry: path.join(__dirname, '/../lambda/my-lambda.ts',),
    handler: 'handler',
    timeout: Duration.minutes(5),
    memorySize: 384,
    tracing: Tracing.ACTIVE,
    paramsAndSecrets,
    environment: {
      SOME_ENV_HERE: 'some-env-here',
    },
    bundling: {
      minify: true,
      sourceMap: true,
      sourceMapMode: SourceMapMode.INLINE,
      target: 'es2022',
      preCompilation: true,
    },
  }
);

Possible Solution

No response

Additional Information/Context

Using "aws-cdk-lib": "2.114.1", the lambda with params and secrets layer lambda extension works successfully with NODEJS_18_X. Upon updating the lambda runtime to NODEJS_20_X we now are seeing errors in CloudWatch:

RequestId: 89fcebe3-f830-4861-8686-f4e7f3c31114 Error: Runtime exited with error: exit status 127
Runtime.ExitError

CDK CLI Version

2.124.0 (build 4b6724c)

Framework Version

No response

Node.js Version

Node 20.11.0

OS

Mac OS X Sonoma 14.3

Language

TypeScript

Language Version

typescript@5.2.2

Other information

No response

pahud commented 7 months ago

This could be a bundling issue using node20 and maybe you need to try DockerImage for the docker-based bundling. This would ensure your code would be bundled in a self-contained environment using node20. This is probably something we could explore and investigate.

github-actions[bot] commented 3 months ago

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.