-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[lambda] 'valueAsString' works well with lazy resolution with lambda environment variables but the type 'Number' does not. #10228
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-lambdaRelated to AWS LambdaRelated to AWS LambdabugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
I am using CfnParameter to read various parameters. One of the parameter types is a 'Number' with min value 1 and max value as 100. This value of this parameter is then passed as the lambda environment key value pairs. When I use 'valueAsNumber' method in conjunction with the lambda environment variables, cdk synth does not synthesize this code for lazy resolution through 'Ref'. It rather assigns a value to the lambda environment variable during synth process. 'valueAsString' works well with lazy resolution with lambda environment variables but the type 'Number' does not.
Reproduction Steps
const numberOfTopics = new CfnParameter(this, 'NumberOfTopics', {
type: 'Number',
default: 10,
minValue: 1,
maxValue: 100,
description: 'The number of topics to be discovered by Topic analysis. The min value is 1 and maximum value is 100'
});
In another section of the code where I read the CfnParameter values
lambdaFunctionProps: {
runtime: Runtime.NODEJS_12_X,
handler: 'index.handler',
code: Code.fromAsset(`${__dirname}/../../lambda/wf-submit-topic-model`),
environment: {
INGESTION_WINDOW: props.ingestionWindow,
RAW_BUCKET_FEED: props.rawBucket.bucketName,
**NUMBER_OF_TOPICS: props.numberofTopics,**
STACK_NAME: props.stackName
},
timeout: Duration.minutes(5),
memorySize: 512
},
What did you expect to happen?
"NUMBER_OF_TOPICS": {
"Ref": "NumberOfTopics"
},
What actually happened?
Environment
- CLI Version: aws-cli/2.0.44 Python/3.8.5 Darwin/19.6.0 source/x86_64
- Framework Version: 1.62.0
- Node.js Version: 14.9.0
- OS: MacOS
- Language (Version): 4.0.2
This is 🐛 Bug Report
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-lambdaRelated to AWS LambdaRelated to AWS LambdabugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2