Skip to content

Cloud-Automation-Portfolio/automation-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Automation Scripts Lab with Compliance, Slack Alerts and Key Rotation

Secure automation of AWS tagging, cleanup, compliance, secret rotation and security scanning—using Python, AWS CLI, open-source tools and GitHub Actions CI/CD.


Table of Contents


Overview

This lab demonstrates secure, real-world AWS automation for:

  • Tagging and cleaning up EC2s (cost & hygiene)
  • Compliance checks and reporting
  • Secret rotation (IAM) and notifications
  • Live Slack alerting for all security actions
  • Open-source security scanning with Prowler
  • Automated scheduling and evidence collection via GitHub Actions

Real-World Risk

Manual AWS operations lead to:

  • Untagged assets and cloud spend overruns.
  • Orphaned instances—wasted resources and attack surface increase.
  • Non-compliant AWS resources and risk of audit/security incidents.
  • Forgotten, stale IAM keys (major breach vector)
  • Security misconfigurations missed by manual review.
  • No team visibility: security actions can go unnoticed.

What I Built

A full-stack AWS automation portfolio lab that:

  • Tags all untagged EC2s for visibility and billing clarity.
  • Cleans up unused stopped EC2s.

Bonuses

  • Runs Prowler for industry-standard AWS security scanning.
  • Automates compliance checks (e.g., EBS encryption), with instant Slack alerts.
  • Rotates IAM secrets and deletes old keys, alerting the team on each action.
  • Runs everything in GitHub Actions, with secure secrets handling.

Diagram

Simple Diagram Lab Architecture2

Detailed Diagram Lab Architecture


Objectives

  • Build secure, modular AWS automation for tagging, cleanup, compliance, secret rotation and reporting.
  • Collect and document “proof” (screenshots, reports) of all automation steps.
  • Integrate Slack and CI/CD for operational visibility.
  • Use AWS security best practices and evidence-driven DevOps.

Steps Performed

1. Project Setup & Folder Structure

  • Created a clean repo: tagging/, cleanup/, compliance/, secrets/, screenshots/ & reports/.
  • Installed AWS CLI, Python 3, boto3, Prowler and configured IAM lab user with least privilege (Screenshot: repo_folder_structure.png)

2. Tagging Automation

  • Wrote and ran a Python script to tag untagged EC2s with a Project: LabAutomation tag.
  • Verified in AWS Console (Screenshots: tagging_script.png, tagging_script_execution.png & ec2s_after_scripts.png)

3. Automated Cleanup

  • Scripted cleanup of stopped EC2s older than 30 days (dry run for safety)
  • Showed pre/post state in AWS Console (Screenshots: cleanup_script.png, cleanup_script_execution.png & ec2s_after_scripts.png)

Bonuses

1.1 Security Scanning with Prowler

  • Ran Prowler AWS security scan and saved results (Screenshots: prowler_security_scan_running.png & prowler_security_scan_results.png)

1.2 Compliance Check Automation

  • Python/boto3 script to detect unencrypted EBS volumes.
  • Integrates with Slack: sends alerts if non-compliance is found (Screenshots: compliance-check-script.png, compliance-check-terminal-output.png & slack-alert-message-channel.png)

1.3 Slack Integration & Notification

  • Created Slack app with Incoming Webhook.
  • Automated notifications from scripts (test, compliance, secret rotation) (Screenshots: slack-app-name-and-workspace.png, slack-enable-incoming-webhooks.png, slack-webhook-url-generated.png, slack-add-webhook-channel.png, slack-channel-message-from-script.png & slack-alert-message-channel.png)

1.4 Secret Rotation Automation

  • Python script rotates IAM user access key, deletes old key and sends Slack alert.
  • Executed via GitHub Actions for auditability (Screenshots: secret-rotation-script.png, rotate-key-slack-alert.png & rotate-key-workflow-success.png)

1.5 Automation as Code: GitHub Actions

  • All automation runs as code, scheduled/triggered in .github/workflows/.
  • GitHub Actions securely injects AWS/Slack secrets via encrypted secrets (Screenshots: github-actions-compliance-workflow-run.png, github-actions-compliance-yaml.png & rotate-key-workflow-success.png)

Screenshots

All screenshots are included in the screenshots/ folder.

Step Filename Description
1 repo_folder_structure.png Folder/project structure in VS Code
2 tagging_script.png Tagging script code in editor
2 tagging_script_execution.png Tagging script output (terminal)
2/3 ec2s_after_scripts.png EC2s after tagging/cleanup (AWS Console)
3 cleanup_script.png Cleanup script code in editor
3 cleanup_script_execution.png Cleanup script output (terminal)
1.1 prowler_security_scan_running.png Prowler running in terminal
1.1 prowler_security_scan_results.png Security findings in Prowler HTML report
1.2 compliance-check-script.png Compliance script code (EBS encryption)
1.2 compliance-check-terminal-output.png Compliance check output (terminal)
1.2 slack-alert-message-channel.png Slack channel message from compliance check
1.3 slack-app-name-and-workspace.png Slack app/workspace selection dialog
1.3 slack-enable-incoming-webhooks.png Slack: Incoming Webhooks enabled
1.3 slack-webhook-url-generated.png Slack: Webhook URL generated (masked)
1.3 slack-add-webhook-channel.png Slack: Added webhook to channel
1.3 slack-channel-message-from-script.png Slack alert from script (test message)
1.3 slack-alert-message-channel.png Slack compliance alert received
1.4 secret-rotation-script.png IAM key rotation script code
1.4 rotate-key-slack-alert.png Slack alert after key rotation
1.4/1.5 rotate-key-workflow-success.png GitHub Actions workflow: key rotation success
1.5 github-actions-compliance-workflow-run.png Compliance workflow run in Actions
1.5 github-actions-compliance-yaml.png Compliance workflow YAML code in GitHub Actions

Lessons Learned

  • How to use Python/boto3 for scalable AWS automation: tagging, cleanup, compliance and key rotation.
  • Integrate Slack for real-time team notifications on cloud security events.
  • Run everything in CI/CD (GitHub Actions) for auditability and production readiness.
  • How open-source security tools (Prowler) fit into continuous cloud security.
  • Portfolio/documentation matters: screenshots & evidence “show not tell” your real skills.

Notes and Limitations

  • Demo scripts are for learning and proof-of-concept—use dry-run and least-privilege in production.
  • Some screenshots are redacted for security.
  • Security scanning coverage (Prowler) can be expanded as needed.
  • Slack webhooks and AWS credentials are always managed as secrets, never in code.

References


Contact

Sebastian Silva C. – August 2025 – Berlin, Germany

About

Secure automation scripts for tagging, cleanup, compliance and secret rotation in AWS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published