This project implements an AWS CloudWatch alarms stack using Terraform. The DevOps team manages 30 CloudWatch alarms for each of the 3 regions in which the company runs its services, resulting in a total of 90 alarms. The goal is to utilize Terraform to define and manage the alarms stack in a consistent and reusable way across regions and environments.
- Configures 3 CloudWatch alarms in each region for dev and prod environments
- Defines a resource for an SNS topic to be used as an action channel when alarms are triggered
- Uses Workspaces to facilitate provisioning the alarms stack in multiple environments and regions
tf_alarm/
├── alarms.Jenkinsfile
├── environments
│ ├── dev.tfvars
│ └── prod.tfvars
├── main.tf
├── outputs.tf
├── regions
│ ├── eu-central-1-prod.tfvars
│ ├── us-east-1-dev.tfvars
│ ├── us-east-1-prod.tfvars
│ └── us-west-1-prod.tfvars
└── variables.tf
main.tf: contains configurations of 3 CloudWatch alarms, as well as the Terraform block with the relevant provider and an S3 backendvariables.tfandoutputs.tf: contain variable definitions and outputsenvironmentsdirectory: contains .tfvars files with per-env variable assignmentsregionsdirectory: contains .tfvars files with per-region variable assignmentsalarms.Jenkinsfile: an almost ready-to-use Jenkinsfile to integrate the alarms pipeline in your Jenkins server
-
Clone the repository:
git clone https://github.com/<username>/<repository>.git -
Modify the .tfvars files in the
environmentsandregionsdirectories with the relevant values for your environment and regions. -
Run the Terraform commands:
terraform init terraform workspace new <workspace-name> terraform apply -var-file=environments/<env>.tfvars -var-file=regions/<region>.tfvars -
Verify that the CloudWatch alarms and SNS topic have been created in your AWS account.
-
Test the system by deploying a change and letting Jenkins provision the new configurations while testing the alarms in action.
This project is licensed under the MIT License - see the LICENSE file for details.
