This project sets up and manages infrastructure on AWS using Terraform. It also integrates with Grafana for monitoring and visualization of infrastructure metrics.
Before starting, ensure you have the following tools installed:
- Terraform (>= 1.0)
- AWS CLI (>= 2.0)
- Installation Guide
- Configured with appropriate credentials:
aws configure
- Grafana
- Installed locally or accessible via a remote server.
- Installation Guide
The infrastructure includes the following components:
- VPC: A Virtual Private Cloud to isolate resources.
- EC2 Instances: Virtual servers for running applications.
- S3 Buckets: For storage purposes.
- RDS: Relational Database Service for managing databases.
- CloudWatch: AWS service for monitoring infrastructure metrics.
- Grafana: For visualizing CloudWatch metrics.
project-directory/
|-- terraform/
| |-- main.tf # Core infrastructure definition
| |-- variables.tf # Input variables
| |-- outputs.tf # Outputs for other modules or external use
| |-- provider.tf # AWS provider configuration
| |-- modules/ # Optional modules for infrastructure
|-- grafana/
|-- dashboards/ # JSON files for Grafana dashboards
|-- config/ # Grafana configuration files
git clone <repository-url>
cd project-directory- Navigate to the
terraform/directory. - Create a
terraform.tfvarsfile to store your variable values (example below):
aws_region = "us-east-1"
instance_type = "t2.micro"
key_name = "your-key-name"
s3_bucket_name = "your-unique-s3-bucket-name"
db_username = "admin"
db_password = "your-secure-password"- Initialize Terraform:
terraform init- Preview the infrastructure changes:
terraform plan- Apply the changes:
terraform apply- Log in to Grafana (default:
http://localhost:3000). - Add AWS CloudWatch as a data source:
- Go to Configuration > Data Sources > Add new data source.
- Select CloudWatch.
- Enter AWS credentials and region.
- Import predefined dashboards from the
grafana/dashboards/folder or create new ones.
- Use Grafana dashboards to visualize metrics such as:
- EC2 instance performance
- S3 bucket usage
- RDS metrics
To destroy the infrastructure, run:
terraform destroy- Fork the repository.
- Create a feature branch (
git checkout -b feature-branch-name). - Commit your changes (
git commit -m "Feature description"). - Push to the branch (
git push origin feature-branch-name). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.