This project provisions a small AWS environment with Terraform, configures the EC2 instance with Ansible, and includes a Jenkins pipeline for repeatable plan/apply/destroy workflows.
- A VPC with a public subnet, internet gateway, and route table
- A security group for SSH, HTTP, and Jenkins-style web traffic
- One Ubuntu EC2 instance prepared for Ansible management
- One versioned S3 bucket with a unique suffix
- An autogenerated Ansible inventory file after
terraform apply
terraform/: AWS infrastructureansible/: inventory, playbooks, and rolesjenkins/: CI/CD pipeline definition
- Terraform 1.5+
- Ansible 2.14+
- AWS CLI configured or Jenkins credentials exported as environment variables
- An existing AWS key pair name for SSH access to the EC2 instance
- Copy
terraform/terraform.tfvars.exampletoterraform/terraform.tfvars - Set values for
aws_region,project_name, andkey_pair_name - Run:
cd terraform
terraform init
terraform plan
terraform apply- After apply, run:
cd ..\ansible
ansible-playbook playbooks/bootstrap.ymlTerraform will generate ansible/inventory/hosts.ini automatically after a successful apply.
The pipeline in jenkins/Jenkinsfile supports:
planapplydestroy
The Jenkins agent should have Terraform and Ansible installed, plus AWS credentials available in the environment.
- The default EC2 instance type is
t3.micro - SSH access is restricted by
allowed_ssh_cidr - The generated web page is a placeholder deployment to demonstrate automated server configuration