Skip to content

Commit

Permalink
Make more config items fully parametrizable
Browse files Browse the repository at this point in the history
Allow a few more elements in lambda_config.template to be parametrized
by environment variables.

In the case of the DynamoDB table names, it's
better if the full name can be parametrized because not everything
necessarily matches the $PROJECT-cdn-$ENV_TYPE pattern (example: the
tables deployed by exodus-gw dev env don't).

In the case of the log format, it's useful to be able to switch the
format so that %(aws_request_id)s is avoided, as that variable won't be
available if the code runs outside the context of Lambda@Edge.

The default values of everything remains the same, except that an
unnecessary "\n" was removed from the end of the log format.
  • Loading branch information
rohanpm committed Mar 25, 2022
1 parent 3bedcdf commit c68bace
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions configuration/lambda_config.template
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"table": {
"name": "$PROJECT-cdn-$ENV_TYPE",
"name": "$EXODUS_TABLE",
"available_regions": [
"us-east-1"
]
},
"config_table": {
"name": "$PROJECT-config-$ENV_TYPE",
"name": "$EXODUS_CONFIG_TABLE",
"available_regions": [
"us-east-1"
]
Expand All @@ -24,7 +24,7 @@
"disable_existing_loggers": "False",
"formatters": {
"default": {
"format": "%(asctime)s - %(levelname)s - %(aws_request_id)s - %(message)s\n",
"format": "$EXODUS_LOG_FORMAT",
"datefmt": "%Y-%m-%d %H:%M:%S"
}
},
Expand Down
3 changes: 3 additions & 0 deletions scripts/mk-config
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ set -e

export ORIGIN_RESPONSE_LOGGER_LEVEL=${ORIGIN_RESPONSE_LOGGER_LEVEL:-WARNING}
export ORIGIN_REQUEST_LOGGER_LEVEL=${ORIGIN_REQUEST_LOGGER_LEVEL:-WARNING}
export EXODUS_LOG_FORMAT="${EXODUS_LOG_FORMAT:-%(asctime)s - %(levelname)s - %(aws_request_id)s - %(message)s}"
export EXODUS_HEADERS_MAX_AGE=${EXODUS_HEADERS_MAX_AGE:-600}
export EXODUS_CONFIG_CACHE_TTL=${EXODUS_CONFIG_CACHE_TTL:-2}
export EXODUS_COOKIE_TTL=${EXODUS_COOKIE_TTL:-720}
export PROJECT=${PROJECT:-exodus}
export ENV_TYPE=${ENV_TYPE:-dev}
export EXODUS_TABLE=${EXODUS_TABLE:-$PROJECT-cdn-$ENV_TYPE}
export EXODUS_CONFIG_TABLE=${EXODUS_CONFIG_TABLE:-$PROJECT-config-$ENV_TYPE}
export EXODUS_SECRET_ARN=${EXODUS_SECRET_ARN}
export EXODUS_KEY_ID=${EXODUS_KEY_ID}

Expand Down

0 comments on commit c68bace

Please sign in to comment.