Cloudformation
Cloudformation
RDS, VPC, and Route 53. Also, AWS CloudFormation can be used to automate the
provisioning and management of resources.
Steps to Follow:
Web Tier Launch an EC2 instance in a public subnet. Configure the security group to
allow HTTP (port 80) and SSH (port 22) from the internet.
Application Tier Launch an EC2 instance in a private subnet. Configure the security
group to allow only SSH (port 22) from the public subnet of the Web Tier.
DB Tier Launch an RDS MYSQL instance in a private subnet. Configure the security
group to allow connections on port 3306 only from the private subnet of the
Application Tier.
Route 53 Create a hosted zone in Route 53. Create a record set to direct traffic to
the EC2 instance of the Web Tier.
AWS CloudFormation To allow the development team to test their code without
involving the system admins, you can use AWS CloudFormation. This service allows
you to model and provision AWS and third-party application resources. You can
create a CloudFormation template that describes all the AWS resources that you want
(like Amazon EC2 instances or Amazon RDS DB instances), and AWS CloudFormation
takes care of provisioning and configuring those resources for you.
AWSTemplateFormatVersion: '2010-09-09'
Description: Template to create Web, Application, and DB Tiers with Route 53 setup
Parameters:
InstanceType:
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- t3.micro
- t3a.micro
Description: EC2 instance type for Web and Application tiers
Resources:
# VPC
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: "true"
EnableDnsHostnames: "true"
AttachInternetGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
Outputs:
WebTierInstancePublicIP:
Description: Public IP of the Web Tier EC2 instance
Value: !GetAtt WebTierInstance.PublicIp
ApplicationTierInstancePrivateIP:
Description: Private IP of the Application Tier EC2 instance
Value: !GetAtt ApplicationTierInstance.PrivateIp
DBInstanceEndpoint:
Description: Endpoint of the RDS MySQL instance
Value: !GetAtt DBInstance.Endpoint.Address
Internet Gateway:
The Internet Gateway allows outbound traffic from the public subnet to the internet
(for SSH and HTTP).
Security Groups:
The Web Tier security group allows HTTP and SSH from anywhere.
The Application Tier security group allows SSH only from the Web Tier.
The DB Tier security group allows MySQL (port 3306) access only from the
Application Tier.
EC2 Instances:
Two EC2 instances are created: one for the Web Tier (in the public subnet) and one
for the Application Tier (in the private subnet).