This project contains Terraform/OpenTofu configurations for deploying AWS infrastructure as part of a thesis examination at Lernia.
This infrastructure-as-code project uses OpenTofu (a Terraform fork) to provision and manage AWS resources including:
- EC2 Instances: Ubuntu 20.04 LTS servers
- DynamoDB Tables: For Terraform state locking
- S3 Buckets: For Terraform state storage with versioning
├── Tofu/ # Main Terraform configuration
│ ├── provider.tf # AWS provider and backend configuration
│ ├── ec2.tf # EC2 instance definitions
│ └── dynamodb.tf # DynamoDB table for state locking
├── modules/ # Reusable Terraform modules
│ └── s3.tf # S3 bucket module for state storage
├── .github/ # GitHub workflows and configurations
├── .vscode/ # VS Code workspace settings
└── README.md # This file
Before using this project, ensure you have:
- OpenTofu (version >= 1.9.1) or Terraform installed
- AWS CLI configured with appropriate credentials
- AWS Account with necessary permissions for:
- EC2 (launch instances, manage security groups)
- DynamoDB (create tables)
- S3 (create buckets, manage objects)
- IAM (if using IAM roles)
The project is configured to use:
- Region:
us-east-1 - Provider: OpenTofu AWS provider (version 6.0.0-beta1)
Terraform state is stored remotely in S3:
- Bucket:
tf-state-bucket-devops-23 - Key:
test/terraform.tfstate - Region:
us-east-1 - Encryption: Enabled
State locking is handled by DynamoDB table tf-locks.
-
Clone the repository:
git clone <repository-url> cd Tofu-aws
-
Navigate to the Terraform directory:
cd Tofu -
Initialize OpenTofu:
tofu init
-
Plan the deployment:
tofu plan
-
Apply the configuration:
tofu apply
To remove all created resources:
tofu destroy- AMI: Ubuntu 20.04 LTS (HVM, SSD)
- Instance Type: t2.micro
- Owner: Canonical (099720109477)
- Name: tf-locks
- Billing Mode: Pay per request
- Hash Key: LockID (String)
- Name: tf-state-bucket-devops-23
- Versioning: Enabled
- Purpose: Terraform state storage
- Terraform state files are encrypted in S3
- State locking prevents concurrent modifications
- Sensitive variables should be stored in
.tfvarsfiles (not committed to version control) - Consider using AWS IAM roles with minimal required permissions
For local development, you can override the backend configuration:
tofu init -backend=false
tofu plan -var-file=local.tfvars- Create new
.tffiles in theTofu/directory - Follow the existing naming conventions
- Update this README with new resource descriptions
- Test with
tofu planbefore applying
- This project uses OpenTofu instead of HashiCorp Terraform
- The infrastructure is designed for educational/demonstration purposes
- Production deployments should include additional security configurations
- Consider adding monitoring, logging, and backup strategies for production use