Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/container-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
runner-os:
- ubuntu-20.04
- ubuntu-latest
steps:

- name: Check out ${{ github.repository }} on disk
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
strategy:
matrix:
runner-os:
- ubuntu-20.04
- ubuntu-latest
runner-python-version:
- 3.6.8 # This is the Python3 version on CI container :shrug:
- "3.10" # This is the Python3 version on CI container :shrug:
steps:

- name: Check out ${{ github.repository }} on disk
Expand Down
14 changes: 8 additions & 6 deletions aws_cleanup/aws_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def run(self):
if not result:
leftovers["s3"].append(bucket)
expired_resources = AWSExpiredResources(
self.ec2_client, self.elb_client, self.elbv2_client, self.s3_client, self.iam_client, self.dry_run
self.ec2_client, self.elb_client, self.elbv2_client, self.s3_client, self.iam_client, self.pricing_client,
self.dry_run
)
expired_resources.eliminate()
print(f"All resources deleted for region {self.ec2_client.meta.region_name}")
Expand Down Expand Up @@ -324,9 +325,10 @@ def get_subnets_from_vpc(self, vpc):
def get_volumes_from_tag(self, tag):
result = []
for volume in self.ec2_client.describe_volumes()["Volumes"]:
for t in volume["Tags"]:
if t["Key"] == "Name" and t["Value"].startswith(tag):
result.append(volume["VolumeId"])
if "Tags" in volume and volume["Tags"]:
for t in volume["Tags"]:
if t["Key"] == "Name" and t["Value"].startswith(tag):
result.append(volume["VolumeId"])
print("Getting EBS volumes", len(result))
return result

Expand Down Expand Up @@ -364,14 +366,14 @@ def get_s3_buckets_expired(self, tag):

class AWSExpiredResources:

def __init__(self, ec2_client, elb_client, elbv2_client, s3_client, iam_client, dry_run=False):
def __init__(self, ec2_client, elb_client, elbv2_client, s3_client, iam_client, pricing_client, dry_run=False):
self.ec2_client = ec2_client
self.elb_client = elb_client
self.elbv2_client = elbv2_client
self.s3_client = s3_client
self.iam_client = iam_client
self.dry_run = dry_run
self.delete = Delete(ec2_client, elb_client, elbv2_client, s3_client, iam_client, dry_run)
self.delete = Delete(ec2_client, elb_client, elbv2_client, s3_client, iam_client, pricing_client, dry_run)

def eliminate(self):
for reservation in self.ec2_client.describe_instances()["Reservations"]:
Expand Down