Commit 19dd98c8 authored by Daniel Taylor's avatar Daniel Taylor

Merge branch 'WID-1413' into 'master'

WID-1413 - Updated to include schedule/unschedule commands and not fail if…

See merge request !2
parents 6d677cf5 bd33eeab
......@@ -22,7 +22,7 @@ import boto3
help="Overrides the error when a custom authorizer isn't set"
)
@click.option(
'--virtualenv_directory',
'--virtualenv-directory',
help="Path to virtualenv directory which contains '/bin/activate'"
)
@click.option(
......@@ -182,6 +182,14 @@ class Zappa:
logging.info("Undeploying {}".format(self.stage))
return self._run("zappa undeploy -y {}".format(self.stage))
def schedule(self):
logging.info("Deploying scheduled task for {}".format(self.stage))
return self._run("zappa schedule {}".format(self.stage))
def unschedule(self):
logging.info("Undeploying scheduled task for {}".format(self.stage))
return self._run("zappa unschedule {}".format(self.stage))
def update(self):
self._update_allowed_hosts(self._get_api_gateway_domain())
logging.info("Updating {}".format(self.stage))
......@@ -266,23 +274,28 @@ class Zappa:
def _update_allowed_hosts(self, api_gateway_domain):
if self.stage not in ['staging', 'production']:
(
self.settings
[self.stage]
['environment_variables']
['ALLOWED_HOSTS']
) = (
self.settings
[self.stage]
['environment_variables']
['ALLOWED_HOSTS']
).replace(
'ZAPPA_ADMIN_API_GATEWAY_DOMAIN_PLACEHOLDER',
api_gateway_domain
)
logging.debug(
"Updated ALLOWED_HOSTS: {}".format(json.dumps(self.settings))
)
try:
(
self.settings
[self.stage]
['environment_variables']
['ALLOWED_HOSTS']
) = (
self.settings
[self.stage]
['environment_variables']
['ALLOWED_HOSTS']
).replace(
'ZAPPA_ADMIN_API_GATEWAY_DOMAIN_PLACEHOLDER',
api_gateway_domain
)
logging.debug(
"Updated ALLOWED_HOSTS: {}".format(
json.dumps(self.settings)
)
)
except KeyError as e:
logging.info("No ALLOWED_HOSTS settings, so not updating it")
class MetricAlarm:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment