In this project, I used Terraform to Provision an Amazon EC2 instnace and automatically configure it as a web server runing Nginx. The infrastructure and configuration were fully automated using infrastructure as Code (Iac)principles.
- infrastructure as Code (Iac)
- Automate server configuration
- Use Terraform provisioners (remote-exec and local-exec)
- Secure SSH access using key pairs
- Automated software installation
- Basic DevOps automation practices
- AWS EC2
- Terraform
- Nginx
- SSh
-Amazon Linux
- Configured the AWS provider
- Defined an EC2 instance resource
- Attached a security group allowing: Port 22(SSH) and Port 80(HTTP)
- Referenced an existing SSH key pair
- Associated the key pair with the EC2 instance
- Used the private key for secure remote access
Used the remote-exec provisioner to:
- Connect to the EC2 instance via SSH.
- Update the system packages.
- Install Nginx
- Start and enabled the Nginx service
This ensured the web server was configured immediately after provisioning
Used the local-exec provisioner to:
- Output the public IP address.
- Display deployment confirmation messages.
- Assist with post deployment verification.
- Accessed the EC2 public_IP address in browser.
- Confirmed that the Nginx default page was displayed
- Verified successful automation from provisioning to application setup
- Executed terraform destroy
- Used local-exec provisioner to display destroy confirmation message
Terraform:
- Terminated the EC2 instance
- Removed the security group
- Cleaned up all associated resources