Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #105 from zalando-stups/odd
Browse files Browse the repository at this point in the history
Add option to disable odd per account
  • Loading branch information
jonathanbeber authored Mar 15, 2021
2 parents 85fa405 + 7d58b03 commit ffc8973
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sevenseconds/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .config.configure import start_configuration, start_cleanup

CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
SUPPORTED_CONFIG_VERSION = 6
SUPPORTED_CONFIG_VERSION = 7


def print_version(ctx, param, value):
Expand Down
7 changes: 6 additions & 1 deletion sevenseconds/config/bastion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def configure_bastion_host(account: AccountData, vpc: object, region: str, base_
cf = account.session.resource('cloudformation', region)
cfc = account.session.client('cloudformation', region)

enable_bastion = account.config.get("enable_odd", True)
re_deploy = account.config['bastion'].get('re_deploy', account.options.get('redeploy_odd_host'))

bastion_version = None
Expand Down Expand Up @@ -91,6 +92,10 @@ def configure_bastion_host(account: AccountData, vpc: object, region: str, base_
]
cloudformation_instances = list(vpc.instances.filter(Filters=cloudformation_filter))
if cloudformation_instances:
if not enable_bastion:
info('bastion not enabled and instances found. Start clean up')
delete_bastion_host(account, region)
return
for instance in cloudformation_instances:
# Terminate old (stopped) Odd Systems
if instance.state.get('Name') == 'stopped':
Expand All @@ -117,7 +122,7 @@ def configure_bastion_host(account: AccountData, vpc: object, region: str, base_
info('check old odd security groups')
cleanup_old_security_group(account, region, oddstack, vpc)

if not legacy_instances and not cloudformation_instances:
if not legacy_instances and not cloudformation_instances and enable_bastion:
try:
stack = cf.Stack('Odd')
info('Stack Status: {}'.format(stack.stack_status))
Expand Down

0 comments on commit ffc8973

Please sign in to comment.