How paduartesre/gitlab-aws works
Project type and purpose
• This is a serverless, event-driven automation system built in Terraform and Python.
• Its purpose is to automate GitLab repository lifecycle and CI/CD settings by collecting repository lists daily, comparing to the previous state, notifying on changes, and enforcing CI configuration rules via merge requests.
File structure
• Top-level Terraform definitions (main.tf, backend.tf, variables.tf) orchestrate the deployment.
• modules/ holds reusable Terraform modules for IAM roles, Lambda functions, SNS topics, and EventBridge schedules.
• lambdas/ contains the two Python functions (collector.py, configurator.py) plus their dependencies.
Key insights from README
• Two Lambda functions triggered daily by EventBridge Scheduler.
• Collector function: queries GitLab (token from Secrets Manager), compares to last list (in SSM Parameter Store), and publishes change notifications to an SNS topic.
• Configurator function: reads the stored list, inspects each repo’s CI/CD settings via GitLab API, and if misconfigured, removes the .gitlab-ci.yml, then opens a merge request to enforce settings.
• Terraform modules define IAM policies for least-privilege access, SNS topic for notifications, and EventBridge rule for scheduling.
• EventBridge Scheduler (cron rule)
• AWS Lambda:
• gitlab_repos_collector
• gitlab_ci_configurator
• AWS Secrets Manager (GitLab service-account token)
• AWS SSM Parameter Store (stored repo list)
• AWS SNS Topic (notification channel + subscription endpoints, e-mail)
• External GitLab API (target system)
• EventBridge → triggers → gitlab_repos_collector
• gitlab_repos_collector → reads token ← Secrets Manager
• gitlab_repos_collector → calls → GitLab API to list repos
• gitlab_repos_collector → compares → previous list in SSM Parameter Store
• gitlab_repos_collector → writes new list → SSM Parameter Store
• gitlab_repos_collector → publishes change events → SNS Topic → email subscribers
• EventBridge → triggers → gitlab_ci_configurator
• gitlab_ci_configurator → reads token ← Secrets Manager
• gitlab_ci_configurator → reads list ← SSM Parameter Store
• gitlab_ci_configurator → for each repo: GitLab API → inspect/remove .gitlab-ci.yml → create merge request if needed
c. Architectural patterns & design principles
• Serverless / event-driven design for cost-efficiency and scalability
• Least-privilege IAM roles scoped per Lambda module
• Infrastructure as code via Terraform modules for reusability and environment parity
• Use of managed services (Secrets Manager, SSM, SNS, EventBridge) to minimize operational overhead
d. Key technologies/frameworks
• AWS Lambda (Python runtime)
• Terraform (root configs + modules: iam, lambda, sns, eventbridge)
• AWS EventBridge Scheduler (daily cron)
• AWS SNS (notification fan-out)
• AWS Secrets Manager & Systems Manager Parameter Store
• GitLab API integration