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

(aws-cdk-lib/aws-lambda): (wrong AWS Parameters and Secrets Lambda Extension environment variables) #26011

Closed
dimalehl opened this issue Jun 16, 2023 · 3 comments · Fixed by #26016
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@dimalehl
Copy link

dimalehl commented Jun 16, 2023

Describe the bug

Wrong environment variables Keys are beeing used to configure the AWS Parameters and Secrets Lambda Extension.
https://github.com/aws/aws-cdk/blob/v2.84.0/packages/aws-cdk-lib/aws-lambda/lib/params-and-secrets-layers.ts#L222

Expected Behavior

Expected environment variables from the AWS docs: AWS Parameters and Secrets Lambda Extension environment variables:
PARAMETERS_SECRETS_EXTENSION_CACHE_ENABLED
PARAMETERS_SECRETS_EXTENSION_CACHE_SIZE
PARAMETERS_SECRETS_EXTENSION_HTTP_PORT
PARAMETERS_SECRETS_EXTENSION_MAX_CONNECTIONS
PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL

Current Behavior

Environment variables set by cdk:

image

CloudWatch logs:

[AWS Parameters and Secrets Lambda Extension] 2023/06/16 08:59:15 PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL is not present. Log level set to info.

Reproduction Steps

import {
  Architecture,
  ParamsAndSecretsLayerVersion,
  ParamsAndSecretsLogLevel,
  ParamsAndSecretsVersions,
  Runtime,
} from 'aws-cdk-lib/aws-lambda';

import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';

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

  const lambda = new NodejsFunction(scope, 'NodejsFunction', {
    runtime: Runtime.NODEJS_18_X,
    architecture: Architecture.ARM_64,
    paramsAndSecrets,
  });

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.84.0 (build f7c792f)

Framework Version

No response

Node.js Version

18.16.0

OS

macOS

Language

Typescript

Language Version

No response

Other information

No response

@dimalehl dimalehl added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jun 16, 2023
@pahud
Copy link
Contributor

pahud commented Jun 16, 2023

Thank you for the feedback.

@pahud pahud added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2023
@colifran colifran self-assigned this Jun 16, 2023
@colifran
Copy link
Contributor

@dimalehl thank you for catching this. I'll get this corrected - should be a quick PR.

@mergify mergify bot closed this as completed in #26016 Jun 16, 2023
mergify bot pushed a commit that referenced this issue Jun 16, 2023
…rets extension (#26016)

This PR corrects a bug where environment variable keys being generated as part of the lambda parameters and secrets extension were being generated at 'PARAMETERS_AND_SECRETS_...' instead of 'PARAMETERS_SECRETS_...'.

Note: existing unit tests were updated to reflect changes to environment variable keys.

Closes #26011

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
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. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants