A small, production‑style AWS web infrastructure built with Terraform, focusing on secure networking, high availability, and team‑friendly remote state.
- Dynamic AMI Selection: Uses Terraform data sources and filters to always pick the latest Amazon Linux AMI, reducing manual image management and keeping instances up to date.
- Network Isolation: The Auto Scaling Group runs only in private subnets with no public IPs. Traffic from the internet always goes through the Application Load Balancer first.
- Remote state and locking: Uses an S3 backend with DynamoDB locking so multiple people can work safely without corrupting Terraform state.
- Security group lifecycle: Uses standalone
aws_vpc_security_group_ingress_ruleandegress_ruleresources instead of inline blocks to make rules easier to track, review, and change over time.
- Region:
eu-west-2(configurable via variables). - High availability: Multi‑AZ deployment across
eu-west-2aandeu-west-2bfor both public and private subnets. - Outbound access: Private instances reach the internet via a NAT gateway in a public subnet, so they can update and pull dependencies without being publicly exposed.
Note: This setup is aimed at a dev environment. For production, a second NAT gateway in another AZ is recommended to avoid a single point of failure.
Important: Never share or commit your AWS credentials or config files. Treat them as sensitive.
- Install AWS CLI on your local machine.
- Create AWS credentials in the AWS Console.
- Configure locally using a named profile:
aws configure --profile dev
- Verify Configuration:
cat ~/.aws/credentials cat ~/.aws/config
Note: This approach is for a dev environment. In production, IAM roles and SSO are to be considered.
- Clone this repo.
git clone https://github.com/RScrafted/aws-infrastructure-baseline.git --progress- Create S3 bucket
unique-name(one-time step). - Create
backend-<env>.hclwith your bucket details (from step 2) and runterraform init -backend-config=backend-<env>.hcl.
- Initialize:
terraform init -backend-config=backend-dev.hcl- Plan & Review:
terraform plan- Deploy:
terraform apply- Post‑Deployment Checks List all deployed resources:
terraform state list- Update the AWS profile in
provider.tfwhen switching environments (dev/test/prod). - AWS Provider version is flexible; currently using:
version = "~> 6.0"
var.tagsis applied inmain.tfalong with resource names for consistent tagging.
terraform destroy


