Using Terraform to deploy a basic architecture for ec2 instances running apache services.
The principal idea is to Work with Terraform and AWS to build this diagram:
The procedure to deploy the infrastructure and the code need the following code:
- Create an AWS account. One option to test is to use free tier aws account.
- Install and configure aws cli
- Install and configure Terraform
Go to the environment, for this example i am using "AWS-EC2-Basic-ARC":
$ cd terraform/
$ git clone https://github.com/tinchom/AWS-EC2-Basic-Arc.git
$ cd terraform/AWS-EC2-Basic-Arc
- Initialised Terraform
$ terraform init
- Validate the configuration
$ terraform validate
- Execute the terraform plan (its going to ask you for key and secret)
$ terraform plan -out AWS-EC2-Basic-ARC.plan
- Apply the terraform plan
$ terraform apply "AWS-EC2-Basic-ARC"
If everything went right, you can view the architecture deployed on your account.
vpc.tf:
This file contain the creation of VPC, Subnet, Internet GW, NAT GW, Route tables, Subnet Associations and Elastic IPs resources.sg.tf:
This file contain the creation of Security Groups resources required for EFS connection.ec2.tf:
This file contain the creation of EC2 resources/instances.vars.tf:
This file contains the variables and values of access keys, secret key, subnet settings and availabilty zones. For this case is set to us-east-1a and us-east-1b.
If all went well you will have 2 instances running in public and private subnets. The private will access to HTTP services running EC2 public instance.