This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 15k traffic Daily!!!

Manage AWS Lambda Environment Variables with CLI Shell Script


On this weblog publish, I introduce a script that permits you to effectively handle the setting variables of an AWS Lambda operate.

This script gives the aptitude to:

  1. Register a brand new variable: Add a brand new setting variable to the Lambda operate.
  2. Replace an current variable: Modify the worth of an current setting variable.
  3. Delete a variable: Take away an setting variable from the Lambda operate.

Essential Be aware on Updating Setting Variables

When utilizing the aws lambda update-function-configuration command to replace the prevailing setting variables, it’s essential to cross each the setting variable you wish to add or replace and all current setting variables. Failing to take action will consequence within the deletion of the prevailing setting variables. The script offered on this weblog publish takes this into consideration and ensures the right dealing with of setting variables throughout the replace course of.



Parameters

function_name: The title of the Lambda operate.

area: The AWS area the place the Lambda operate is deployed.

env_vars_upsert: Key-value pairs of setting variables to be upserted (up to date or inserted).

  • Through the upsert course of, the setting variable shall be up to date if it exists; in any other case, a brand new one shall be registered.

  • You may embrace any variety of key-value pairs.

env_vars_upsert=(
  "MY_ENV1" "value1"
  "MY_ENV2" "value2"
)
Enter fullscreen mode

Exit fullscreen mode

env_vars_remove: Keys of setting variables to be eliminated.

  • If the required key doesn’t exist, nothing will occur.
env_vars_remove=("MY_ENV3" "MY_ENV4")
Enter fullscreen mode

Exit fullscreen mode



Output

The script will response in JSON format. The “Setting” part will show the up to date state of the setting variables.

{
    "FunctionName": "xxxx",
    ...

    "Setting": {
        "Variables": {
            "MY_ENV2": "value2",
            "MY_ENV1": "value1"
        }
    },
    ...
}
Enter fullscreen mode

Exit fullscreen mode



Abstract

I launched a shell script for managing AWS Lambda environmental variables, enabling customers to register, replace, and delete variables with ease. This script additionally takes into consideration the prevention of unintentional deletions, making certain protected and environment friendly administration of your Lambda operate’s environmental variables.



Warning

Earlier than utilizing this script in a manufacturing setting, please create a check Lambda operate and check it completely to make sure it really works as anticipated.

The Article was Inspired from tech community site.
Contact us if this is inspired from your article and we will give you credit for it for serving the community.

This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 10k Tech related traffic daily !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?