Skip to content

Commit

Permalink
fix: handle destroy with missing security group
Browse files Browse the repository at this point in the history
  • Loading branch information
karsten-adot committed Dec 10, 2024
1 parent c3dee6d commit d8f996c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flintrock/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,15 @@ def destroy(self):
time.sleep(1)

# TODO: Centralize logic to get cluster security group name from cluster name.
cluster_group = list(
cluster_group_list = list(
ec2.security_groups.filter(
Filters=[
{'Name': 'group-name', 'Values': ['flintrock-' + self.name]},
{'Name': 'vpc-id', 'Values': [self.vpc_id]},
]))[0]
cluster_group.delete()
]))
# Cluster group might already have been killed if a destroy was ungracefully stopped during a previous execution
if len(cluster_group_list) > 0:
cluster_group_list[0].delete()

(ec2.instances
.filter(
Expand Down

0 comments on commit d8f996c

Please sign in to comment.