Skip to content

Commit f892312

Browse files
Elad Ben-Israelmergify[bot]
authored andcommitted
fix(lambda): environment var values are strings (#3858)
* fix(lambda): environment var values are strings AWS Lambda requires that all environment variables will be strings but the API indicated `any` as the type of the value. If users would pass in a non-string value, they would see an error only during deployment. Fixes #3337 * remove redundant null-check on this.environment * add breaking change excludes
1 parent a09203a commit f892312

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

allowed-breaking-changes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ removed:@aws-cdk/aws-apigateway.HttpIntegration.props
1212
removed:@aws-cdk/aws-apigateway.Integration.props
1313
removed:@aws-cdk/aws-apigateway.LambdaIntegration.props
1414
removed:@aws-cdk/aws-apigateway.MockIntegration.props
15+
incompatible-argument:@aws-cdk/aws-lambda.Function.<initializer>
16+
incompatible-argument:@aws-cdk/aws-lambda.SingletonFunction.<initializer>
17+
incompatible-argument:@aws-cdk/aws-lambda.Function.addEnvironment

packages/@aws-cdk/aws-lambda/lib/function.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export interface FunctionProps {
7676
*
7777
* @default - No environment variables.
7878
*/
79-
readonly environment?: { [key: string]: any };
79+
readonly environment?: { [key: string]: string };
8080

8181
/**
8282
* The runtime environment for the Lambda function that you are uploading.
@@ -392,7 +392,7 @@ export class Function extends FunctionBase {
392392
/**
393393
* Environment variables for this function
394394
*/
395-
private readonly environment?: { [key: string]: any };
395+
private readonly environment: { [key: string]: string };
396396

397397
constructor(scope: Construct, id: string, props: FunctionProps) {
398398
super(scope, id, {
@@ -491,11 +491,7 @@ export class Function extends FunctionBase {
491491
* @param key The environment variable key.
492492
* @param value The environment variable's value.
493493
*/
494-
public addEnvironment(key: string, value: any): this {
495-
if (!this.environment) {
496-
// TODO: add metadata
497-
return this;
498-
}
494+
public addEnvironment(key: string, value: string): this {
499495
this.environment[key] = value;
500496
return this;
501497
}

0 commit comments

Comments
 (0)