-
Notifications
You must be signed in to change notification settings - Fork 1
feat: directly update the basemaps lambda function configuration #1086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
blacha
wants to merge
1
commit into
master
Choose a base branch
from
build/update-lambda-config-directly
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
# | ||
# Basemaps uses environment variables to know where to load config from | ||
# | ||
# This script looks up the current environment variables for the lambda | ||
# then updates the config location to the new config location | ||
# | ||
# Parameters: | ||
# - $BASEMAPS_CONFIG_LOCATION - location of the new configuration file | ||
# - $BASEMAPS_LAMBDA_ARN - ARN of the lambda to update | ||
|
||
if [ -z "$BASEMAPS_CONFIG_LOCATION" ]; then | ||
echo "Error: missing config location \$BASEMAPS_CONFIG_LOCATION" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$BASEMAPS_LAMBDA_ARN" ]; then | ||
echo "Error: missing config location \$BASEMAPS_LAMBDA_ARN" | ||
exit 1 | ||
fi | ||
|
||
# Get the Lambda function's current environment variables | ||
existing_env_vars=$(aws lambda get-function-configuration \ | ||
--region ap-southeast-2 \ | ||
--function-name "$BASEMAPS_LAMBDA_ARN" \ | ||
--query "Environment.Variables" \ | ||
--output json) | ||
|
||
current_location=$(echo "$existing_env_vars" | jq ".BASEMAPS_CONFIG_PATH") | ||
# Use jq to update the configuration path | ||
updated_env_vars=$(echo "$existing_env_vars" | jq ".BASEMAPS_CONFIG_PATH = \"${BASEMAPS_CONFIG_LOCATION}\"") | ||
|
||
# Update the Lambda function with the modified environment variables | ||
aws lambda update-function-configuration \ | ||
--region ap-southeast-2 \ | ||
--function-name "$BASEMAPS_LAMBDA_ARN" \ | ||
--environment Variables="$updated_env_vars" | ||
|
||
echo "Updated config location from: ${current_location} to ${BASEMAPS_CONFIG_LOCATION}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nice and easy for update the environment variables. Just wondering if we want to wrap this into a cli?
And also we might still want to compare and comment changes for between old config and new config in the PR for preview changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was duplicated in two places is why I made it a bash shell, we could write a full cli for it, but figured it wasn't really worth it to wrap 2 aws sdk calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comparison between the config diffs, is also already handled futher up the script this is just the deployment phase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just need to update the
import
cli tocompare
cli, which is download production config from v1/version and do diffs between Pull request config. So we still got the diffs.