#!/bin/bash -eu # set_environment_variable.sh: set one environment variable for an AWS lambda function func=$1 var=$2 value=$3 vars=$(aws lambda get-function-configuration --function-name "$func" --query 'Environment.Variables') if [ "$vars" = "null" ]; then vars = "{}" fi echo "old vars: $vars" # NOTE: This won't work with values that need escaping, maybe do this in Python instead. vars=$( echo "$vars" | jq ".$var = \"$value\"" ) confirm aws lambda update-function-configuration --function-name bitskins_ws_realtime --environment "$vars"