Detects and removes orphaned SNS subscriptions that belong to non-existent topics.
Runs in dry run mode to log orphaned subscriptions only or in production mode to perform cleanup operations.
- Java >= 8
- Maven >= 3.6.x
- AWS SAM CLI
- Docker >=17.x (optional - for local Lambda setup)
Parameter | Type | Default | Description |
---|---|---|---|
DRY_RUN |
Environment variable | true |
Disables dry run mode to perform cleanup steps. Otherwise abandoned subscriptions are logged only. |
Schedule |
CloudWatch event config | cron(0 0 * * ? *) |
Defines how often the cleanup function will run. Defaults to every 24 hours at midnight. |
Policies |
Lambda function policies | AmazonSNSReadOnlyAccess |
To perform cleanup, write access to SNS is required. |
See template.yml for further details.
sam build
mvn test
sam deploy --guided
sam logs -n SnsAbandonedSubscriptionCleaner --stack-name sns-abandoned-subscription-cleaner --tail
...
<timestamp> Checking topic arn:aws:sns:us-west-2:foo:bar.
<timestamp> Checking topic arn:aws:sns:us-west-2:foz:baz.
<timestamp> No abandoned subscriptions found.
<timestamp> Dry run mode. Skipping subscription cleanup.
See .github/workflows.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.