Jenkins EC2 Instance, S3 Backend & AWS Backup Vault
23 minIntermediate
This creates billable resources. Run it in a dev environment and destroy it when you finish. Set a budget alarm first.
Success criteria
0 of 3
What you are building#
What is the Jenkins Host & AWS Backup Architecture?#
- Jenkins Host: Dedicated EC2 host in Public Subnet A running Jenkins LTS, Docker CE, and CI/CD tools. Attached to a persistent Elastic IP (EIP).
- AWS Backup Vault: Fully managed enterprise backup service. Executes automated daily snapshots of the Jenkins EC2 EBS volume at 05:00 UTC with 30-day retention policies.
- Remote State Backend: S3 bucket with DynamoDB state locking to prevent concurrent state corruption during multi-developer terraform runs.
text
JENKINS EC2 & DISASTER RECOVERY
+-----------------------------------------------------------------------------------+
| PUBLIC SUBNET A (VPC) |
| - Jenkins EC2 Instance (Elastic IP Attached) |
| - EBS Root Volume (gp3, 30GB Encrypted) |
+----------------------------------------+------------------------------------------+
|
| Daily Automated Snapshot at 05:00 UTC
v
+-----------------------------------------------------------------------------------+
| AWS BACKUP VAULT (nti-devops-backup-vault) |
| - Rule: Daily Snapshots |
| - Retention: 30 Days |
| - Encryption: KMS Key |
+-----------------------------------------------------------------------------------+Steps#
Step 1: Initialize S3 Remote Backend & Apply Master Infrastructure#
Terminal
cd 01-Infrastructure-Terraform/Lab06-Jenkins-EC2-AWSBackup
terraform init
terraform apply -auto-approveVerify it worked#
Terminal
terraform outputExpected Output:
text
jenkins_public_ip = "54.210.142.88"
eks_cluster_name = "nti-devops-eks"
rds_endpoint = "nti-devops-postgres.c123456789.us-east-1.rds.amazonaws.com"Clean up#
Run this even if you did not finish. Everything above is destroyable, and an account full of half-built experiments is how a surprise bill starts.
Destructive — This removes real resources. Check which environment you are in first.
Terminal
terraform destroy -auto-approve
aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[].Instances[].InstanceId'
aws backup list-recovery-points-by-backup-vault --backup-vault-name <vault> --query 'RecoveryPoints[].RecoveryPointArn'Cost of this lab: Free tier — a t3.micro EC2 instance and S3 storage are inside the 12-month allowance. Outside it, expect ~$8/month for the instance if left running. AWS Backup charges for stored recovery points.