📑

Lambdaの環境変数がCodeタブでも見られるようになった

2023/06/30に公開

アップデート

  • Lambdaの環境変数をCodeタブから一覧表示できるようになった
  • Configurationページに行くことなく、環境変数が見られるのがポイント

https://aws.amazon.com/jp/about-aws/whats-new/2023/06/aws-lambda-copying-environment-variables-console-code-editor/

Posted On: Jun 29, 2023
AWS Lambda console code editor now includes a read file listing all the environment variables associated with the function, making it easier for developers to discover the variables and reference them in their code.
...
With this launch, developers can conveniently view their function's version specific environment variables and copy the keys to be referenced in their code from the read file within the editor, avoiding navigating to the functions configuration page.

デモ

  1. Configuration -> Environmental Variablesで環境変数を表示した状態(※通常はこの画面で環境変数を見る)
  2. Codeタブに移る -> Tools -> Show Environmental Variablesをクリック
  3. Environmental Variablesタブが開く、環境変数が表示されている

Environmental Variablesタブに表示されていること

新しく開くタブに書いてあることは、ここでの環境変数に関する説明です。

  • ショートカットはCtrl-Shift-E
  • 暗号化されている
  • ReadOnlyで、Lambdaのコンソールのみで使える。zipでダウンロードしても含まれない。変更するならConfigurationタブから

Environment Variables
To list your environment variables here for quick reference, use the keyboard shortcut (For macOS, press 'Command-Shift-E' for Windows 'Ctrl-Shift-E') or choose Tools, Show Environment Variables.

Environment variables remain encrypted when listed in the console code editor. If you enabled encryption helpers for encryption in transit, then those settings remain unchanged. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption.

This file is read-only and is only available on the Lambda console. This file is not included when you download the function's .zip file archive and you can't add environment variables by uploading this file. To add or edit environment variables, choose Configuration, then choose Environment variables.

List of environment variables

環境変数一覧がkey = value の形で出力されます。

まとめ

  • LambdaのCodeタブから環境変数を一覧表示できます(知らなかっただけかもしれないですが)
  • 環境変数を多用する時に便利そうです
  • (・・・個人的には必要性が未だわからないです)

Discussion