MozillaFoundation / foundation.mozilla.org

Mozilla Foundation website
https://foundation.mozilla.org
Mozilla Public License 2.0
387 stars 153 forks source link

Run AWS Script to clean designated buckets #12283

Open data-sync-user opened 5 months ago

data-sync-user commented 5 months ago

Tom has shared with us the script that needs to be used to clean AWS of the buckets that the team had designated as safe to remove.

import boto3

buckets = [
    "2015.mozillafestival.org-redirect",
    "advocacy-media-uploads-s3bucket-1bksegc8ljpyd",
    "advocacy-mozilla-org-s3bucket-1q006bfcakzf1",
    "application-log-archive",
    "apps-webmaker-org-static-s3bucket-gkz37dd8kkyu",
    "blog-mozillaignite-org-s3bucket-pfa7xcd5jc9m",
    "blog-webmaker-org-redirect",
    "book-mozillafoundation-org-s3bucket-4hskoi4m627q",
    "build-mozillafoundation-org-redirect",
    "call-power-demo-mozilla",
    "community-openbadges-org-production-s3bucket-8k5i4xs0dcn9",
    "elasticbeanstalk-us-east-1-152582112771",
    "foundation-mozilla-org-visual-ci",
    "foundation-site-copy",
    "gigabit-website-redirects",
    "global-sprint-2018-data",
    "goggles-webmaker-org-redirect-s3bucket-1dd68hxz4un3d",
    "hardhat-redirect",
    "health-report",
    "iheartopendata-redirect",
    "iheartopendata.org",
    "internet-health-report",
    "jisort",
    "mattermoz-logging-production",
    "mattermoz-production",
    "mattermoz-staging",
    "mofo-beanstalk",
    "mofo-code-deploy",
    "mofo-spam-test",
    "mofo-terraform",
    "mozfest-schedule-redirect-s3bucket-1rfoe5pm8tbcz",
    "mozilla-bsd-cache",
    "mozilla-foundation-iot",
    "mozilla-foundation-org-maintenance",
    "mozilla-foundation-research",
    "mozilla-ventures-lp",
    "net-gain-challenge-redirect-s3bucket-1v8lqwko944ta",
    "netgainpartnership.org",
    "network-api-media-uploads",
    "network-production",
    "network-smoketest",
    "network-staging",
    "network-unity",
    "openbadgespec.org-static",
    "opennews-org-production-s3bucket-1hn6jhpq36wi3",
    "paper-storm-tiles-production",
    "popcorn-webmadecontent-org-s3bucket-ccjrxol4tfyl",
    "responsible-design.org-static",
    "science-mozilla-org-blog-redirect",
    "stuff-webmaker-org-s3bucket-hr2hzgnaatng",
    "thimbleprojects.org-redirect",
    "webmaker-deprecated-sites-s3bucket-15kz0pphzvcaz",
    "webmaker-org-redirect",
    "www.mozfest.org",
    "cf-templates-vzit3vgymiyb-us-east-1",
    "foundation-sandbox",
    "convox-fundraising-registrybucket-d4tqmtzzhkkp",
    "convox-fundraising-settings-875r4l5pwhnm",
    "convox-registrybucket-8qxitwhmwi8yInfo",
    "convox-settings-712hwcu08rpm",
    "eoy2014-api",
    "logs-s3bucket-1qkkk2485xips",
    "mofo-repos",
    "mofo-transaction-storage-settings-9yhu44dg5yxw",
    "mofo-transaction-storage-settings-m6j4amn8nko3",
]

s3 = boto3.resource('s3')

for bucket in buckets:
    print("Deleting "+ bucket)
    try:
        bucket = s3.Bucket(bucket)
        bucket.objects.all().delete()
        bucket.object_versions.delete()
        bucket.delete()
    except s3.meta.client.exceptions.NoSuchBucket:
        print("Bucket already deleted")

We would need to run this script in order to finally close any AWS cleanup related tickets. This code snippet might also be a good thing to save as documentation in case we need to run similar commands in the future.

┆Issue is synchronized with this Jira Task

data-sync-user commented 4 days ago

➤ Simon Acosta Torres commented:

Hubert Ostrowski Assigning this to you just to confirm that this task is now done. Thank you!

data-sync-user commented 4 days ago

➤ Hubert Ostrowski commented:

Simon Acosta Torres Script was run, and all marked the buckets were verified and deleted. Due to iaas infrastructure of some projects, some of them might be recreated in future, however those are edge cases