Skip to content

Commit

Permalink
chore(lambda): add AWS_DEFAULT_REGION to the list of reserved environ…
Browse files Browse the repository at this point in the history
…ment variables (#28048)

### Changes
- added `AWS_DEFAULT_REGION` to `reservedEnvironmentVariables`
  - unit tests were not added because there is only one existing test case written.
    - https://github.com/aws/aws-cdk/blob/91a3e8c0fb0b6e91d45146c44c234151c59b3476/packages/aws-cdk-lib/aws-lambda/test/function.test.ts#L3426 

### Description
The Function constructor checks that reserved environment variables are not specified when adding environment variables.
However, when I mistakenly specified `AWS_DEFAULT_REGION` as an environment variable,  `cdk synth` did not generate an error.

The following document contains the list of reserved environment variables.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime

Cloudformation gives the following error.
`Resource handler returned message: "Lambda was unable to configure your environment variables because the environment variables you have provided contains reserved keys that are currently not supported for modification. Reserved keys used in this request: AWS_DEFAULT_REGION`

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
sakurai-ryo authored Nov 17, 2023
1 parent 15f7b7a commit 4713547
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-lambda/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ export class Function extends FunctionBase {
const reservedEnvironmentVariables = [
'_HANDLER',
'_X_AMZN_TRACE_ID',
'AWS_DEFAULT_REGION',
'AWS_REGION',
'AWS_EXECUTION_ENV',
'AWS_LAMBDA_FUNCTION_NAME',
Expand Down

0 comments on commit 4713547

Please sign in to comment.