{"id":13625951,"url":"https://github.com/trackit/aws-clean-untagged-resources","last_synced_at":"2025-05-12T14:54:39.274Z","repository":{"id":43375066,"uuid":"338112574","full_name":"trackit/aws-clean-untagged-resources","owner":"trackit","description":"AWS Clean Untagged Resources will notify you on Slack and terminate/stop untagged EC2/RDS resources!","archived":false,"fork":false,"pushed_at":"2023-01-16T14:54:21.000Z","size":59,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T23:30:04.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trackit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-11T18:14:45.000Z","updated_at":"2024-02-26T15:15:25.000Z","dependencies_parsed_at":"2023-02-10T04:15:38.295Z","dependency_job_id":null,"html_url":"https://github.com/trackit/aws-clean-untagged-resources","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trackit%2Faws-clean-untagged-resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trackit%2Faws-clean-untagged-resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trackit%2Faws-clean-untagged-resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trackit%2Faws-clean-untagged-resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trackit","download_url":"https://codeload.github.com/trackit/aws-clean-untagged-resources/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253759495,"owners_count":21959774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:02:06.405Z","updated_at":"2025-05-12T14:54:39.252Z","avatar_url":"https://github.com/trackit.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# AWS-Clean Untagged Resources\n\nThis script will notify you on Slack and terminate/stop untagged EC2/RDS resources!\n\n## 📚 Usage\n\nThe project is using Lambda to periodically check your AWS account for untagged or not persistent EC2, RDS \u0026 ECS with Fargate resources.\nIt has 3 possible behavior:\n- *NOTIFY*: This mode will scan for untagged EC2/RDS instances and send a message on your Slack workspace\n- *STOP*: This mode will scan for untagged EC2/RDS instances and stop them\n- *TERMINATE*: This mode will scan for untagged EC2/RDS instances and terminate them\n\nThe Lambda will also check for resources tagged with a lifetime tag to be able to define from when a resource should be\nterminated. For example if we have the tag `Lifetime`=`10`, it means that the resource should live at least 10 days and the\nlambda won't stop/terminate this resource until the lifetime has been expired or `Lifetime`=`yyyy-mm-dd` to directly define\nan expiration date for the resource.\n\n### Package\n\nBefore deploying the lambda function you'll have to make a zip of your code like the following:\n\n```sh\n$ cd aws-clean-untagged-resources\n```\n\nMake sure that you've installed dependencies, if not you can use the following command:\n\n```sh\n$ pip3 install --target ./package -r requirements.txt\n```\n\nYou're now able to zip your packages (you can skip this part if packages were already zipped:\n\n```sh\ncd package\nzip -r ../../aws-clean-untagged-resources.zip .\ncd ..\n```\n\nNow everytime you do some changes on your code you will have to zip your code like the following:\n\n```sh\nzip -g ../aws-clean-untagged-resources.zip *.py\n```\n\nDocumentation sources: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-create-package-with-dependency\n\n### 🚀 Deploy\n\nYou will need a S3 bucket in order to deploy the Lambda with Cloudformation\nYou will need to create a Slack webhook on your slack workspace\n\nTo deploy the function, replace the variables in the following commands:\n```sh\n$ aws cloudformation package --template-file template.yml --s3-bucket YOUR_DEPLOYMENT_BUCKET --s3-prefix YOUR_S3_PREFIX --output-template-file output.yaml\n$ aws cloudformation deploy --template-file output.yaml --stack-name STACK_NAME --capabilities CAPABILITY_NAMED_IAM --parameter-overrides SlackWebHook=YOUR_SLACK_WEBHOOK_URL ScheduleExpression=\"cron(0 16 ? * THU *)\" PersistentTagKey=MY_RESOURCE_TAG_NAME PersistentTagValue=MY_RESOURCE_TAG_VALUE LifetimeTagKey=LIFETIME_TAG_KEY Behavior=notify|stop|terminate AwsRegions=AWS_REGIONS\n```\n*Usage example*: If you want to notify on Slack about untagged resources on Thursday at 4pm and stop them on Sunday at 4pm you will need to deploy 2 stacks with the following:\n```sh\n$ aws cloudformation package --template-file template.yml --s3-bucket YOUR_DEPLOYMENT_BUCKET --s3-prefix YOUR_S3_PREFIX --output-template-file output.yaml\n$ aws cloudformation deploy --template-file output.yaml --stack-name STACK_NAME-notify --capabilities CAPABILITY_NAMED_IAM --parameter-overrides SlackWebHook=YOUR_SLACK_WEBHOOK_URL ScheduleExpression=\"cron(0 16 ? * THU *)\" PersistentTagKey=MY_RESOURCE_TAG_NAME PersistentTagValue=MY_RESOURCE_TAG_VALUE Behavior=notify AwsRegions=AWS_REGION1,AWS_REGION2 LifetimeTagKey=LIFETIME_TAG_KEY\n$ aws cloudformation deploy --template-file output.yaml --stack-name STACK_NAME-stop --capabilities CAPABILITY_NAMED_IAM --parameter-overrides SlackWebHook=YOUR_SLACK_WEBHOOK_URL ScheduleExpression=\"cron(0 16 ? * SUN *)\" PersistentTagKey=MY_RESOURCE_TAG_NAME PersistentTagValue=MY_RESOURCE_TAG_VALUE Behavior=stop AwsRegions=AWS_REGION1,AWS_REGION2 LifetimeTagKey=LIFETIME_TAG_NAME\n```\n\n### 💣 Destroy\n\n```sh\n$ aws cloudformation delete-stack STACK_NAME\n```\n\n## 🤝 Missing a specific feature?\n\nFeel free to ask for the features you want! Our teams will be happy to add them!\n\n## ❤️ Show your support\n\nGive a ⭐️ if this project helped you!\n\n## ✏️ Author\n\n### 👤 Trackit\n- Website: [trackit.io](www.trackit.io)\n\n### 👥 About us\n\nWe are an Amazon Web Services Advanced Consulting Partner specializing in cloud management, consulting, and software development solutions based in Venice, CA.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrackit%2Faws-clean-untagged-resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrackit%2Faws-clean-untagged-resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrackit%2Faws-clean-untagged-resources/lists"}