A terraform file that deploys an EC2 (publicly accessible with ssh and http/https) with apache2 installed on AWS.
The following resources created to achieve that goal.
- Create vpc
- Create Internet Gateway
- Create Custom Route Table
- Create a Subnet
- Associate subnet with Route Table
- Create Security Group to allow port 22,80,443
- Create a network interface with an ip in the subnet that was created in step 4
- Assign an elastic IP to the network interface created in step 7
- Create Ubuntu server and install/enable apache2
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
Note: Here is the official doc https://learn.hashicorp.com/tutorials/terraform/install-cli
- Run
terraform init
to initialize terraform and install dependencies (providers)
- Run
terraform apply -auto-approve
to deploy the infastructure on AWS
Note: Deployment will throw and error because its missing the
aws_secret_key
,aws_access_key
, andkey_name
. Please fill them on theterraform.tfvars
file with your credentials