From bde4d356bf2fe789449abcfd151702d15491df03 Mon Sep 17 00:00:00 2001 From: Tim Gion Date: Thu, 8 Jun 2017 15:00:52 -0400 Subject: [PATCH] Set DEV_STACK variable if deploying to a dev stack This forces the autoscale lambda to use smaller tables for DynamoDB to save money. The production min values are still way too high for use in the dev stacks. --- cloud_formation/configs/dynamolambda.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cloud_formation/configs/dynamolambda.py b/cloud_formation/configs/dynamolambda.py index 9735a2a3..7de408be 100644 --- a/cloud_formation/configs/dynamolambda.py +++ b/cloud_formation/configs/dynamolambda.py @@ -64,6 +64,12 @@ # written to SLACK_WEBHOOK_PATH. VPC_DOMAIN = 'VPC_DOMAIN' +# Used to override normal autoscale rules when creating a developer's stack. +# All tables will use the autoscale rules defined by the "default" config to +# avoid spending too much. The production autoscale rules have minimums that +# are way too high for DynamoDB tables for developers. +DEV_STACK = 'DEV_STACK' + def create_config(session, domain): """ Create the CloudFormationConfiguration object. @@ -166,6 +172,8 @@ def update_config_file(config_str, domain): config_str (str): String representation of config file template. """ parser = configparser.ConfigParser() + # Disable default transform to lowercase of keys. + parser.optionxform = lambda option: option parser.read_string(config_str) parser.set('default', VPC_DOMAIN, domain) @@ -176,6 +184,10 @@ def update_config_file(config_str, domain): parser.set('default', SLACK_WEBHOOK_PATH, slack_path_prod) else: parser.set('default', SLACK_WEBHOOK_PATH, slack_path_dev) + if domain != 'integration.boss': + # Override normal autoscale parameters when deploying to a + # developer stack. + parser.set('default', DEV_STACK, '') slack_path = parser.get('default', SLACK_WEBHOOK_PATH) # Remove stack specific variables before outputting.