@@ -19,6 +19,7 @@ def configure_bastion_host(account: AccountData, vpc: object, region: str, base_
19
19
cf = account .session .resource ('cloudformation' , region )
20
20
cfc = account .session .client ('cloudformation' , region )
21
21
22
+ enable_bastion = account .config .get ("enable_odd" , True )
22
23
re_deploy = account .config ['bastion' ].get ('re_deploy' , account .options .get ('redeploy_odd_host' ))
23
24
24
25
bastion_version = None
@@ -91,6 +92,10 @@ def configure_bastion_host(account: AccountData, vpc: object, region: str, base_
91
92
]
92
93
cloudformation_instances = list (vpc .instances .filter (Filters = cloudformation_filter ))
93
94
if cloudformation_instances :
95
+ if not enable_bastion :
96
+ info ('bastion not enabled and instances found. Start clean up' )
97
+ delete_bastion_host (account , region )
98
+ return
94
99
for instance in cloudformation_instances :
95
100
# Terminate old (stopped) Odd Systems
96
101
if instance .state .get ('Name' ) == 'stopped' :
@@ -117,7 +122,7 @@ def configure_bastion_host(account: AccountData, vpc: object, region: str, base_
117
122
info ('check old odd security groups' )
118
123
cleanup_old_security_group (account , region , oddstack , vpc )
119
124
120
- if not legacy_instances and not cloudformation_instances :
125
+ if not legacy_instances and not cloudformation_instances and enable_bastion :
121
126
try :
122
127
stack = cf .Stack ('Odd' )
123
128
info ('Stack Status: {}' .format (stack .stack_status ))
0 commit comments