{"id":1976,"date":"2020-06-01T16:27:07","date_gmt":"2020-06-01T13:27:07","guid":{"rendered":"https:\/\/artem.services\/?p=1974"},"modified":"2020-06-02T17:41:39","modified_gmt":"2020-06-02T14:41:39","slug":"1976","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1976&lang=en","title":{"rendered":"AWS Cli &#8212; Lambda: Update single variable value"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-214\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png\" alt=\"\" width=\"975\" height=\"450\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png 975w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-300x138.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-768x354.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-954x440.png 954w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/p>\n<p>Key &quot;<strong>&#8212;environment<\/strong>&quot; <strong>AWS Cli<\/strong> utility replaces all the variables, those that you specify as an argument. To change the value of only one variable without erasing the others, or without listing them all, you can use the following <strong>BASH<\/strong> script:<\/p>\n<h3>aws_lambda_update_env.sh:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/env bash\r\n\r\n# VARIABLES\r\nLAMBDA='ARTEM-SERVICES'\r\nREGION='us-east-1'\r\nVARIABLE='ECR_TAG'\r\nNEW_VALUE='1.0.1'\r\n\r\nCURRENTVARIABLES=&quot;$(aws lambda get-function-configuration --region $REGION --function-name $LAMBDA | jq '.Environment.Variables')&quot;\r\n\r\nNEWVARIABLES=$(echo $CURRENTVARIABLES | jq --arg VARIABLE $VARIABLE --arg NEW_VALUE $NEW_VALUE &quot;.$VARIABLE |= \\&quot;$NEW_VALUE\\&quot;&quot;)\r\n\r\nCOMMAND=&quot;aws lambda update-function-configuration --region $REGION --function-name $LAMBDA --environment '{\\&quot;Variables\\&quot;:$NEWVARIABLES}'&quot;\r\n\r\neval $COMMAND\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>This script requires <strong>jq<\/strong> utility<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>The script reads all current variables, changes the value of the variable &quot;<strong>ECR_TAG<\/strong>&quot; to the value &quot;<strong>1.0.1<\/strong>&quot; and updates all the variables with the changed value of the variable &quot;<strong>ECR_TAG<\/strong>&quot;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Key &quot;&#8212;environment&quot; AWS Cli utility replaces all the variables, those that you specify as an argument. To change the value of only one variable without erasing the others, or without listing them all, you can use the following BASH script: aws_lambda_update_env.sh: &nbsp; This script requires jq utility &nbsp; The script reads all current variables, changes &hellip; <a href=\"https:\/\/artem.services\/?p=1976&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;AWS Cli &#8212; Lambda: Update single variable value&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[599,415],"tags":[543,647,427,885],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1976"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1976"}],"version-history":[{"count":3,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1976\/revisions"}],"predecessor-version":[{"id":1979,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1976\/revisions\/1979"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}