Effortless Application Deployment with AWS CloudFormation: One-Click Deployment Made Easy
- What is CloudFormation and it’s need...?
CloudFormation provides you single click deployment within few minutes basically you need to create a template of CloudFormation template consist of multiple service as you needed to be created in AWS and third party so this is best service to mange your services in AWS.
So, in this blog I cover with the help of AWS CloudFormation deploy sample web app which is in “HTML”
2. Login AWS Console and go to CloudFormation Service
3. Now create on stack button
4. Now in Prerequisites select as by default option
5. after that select “upload template file” option and choose file
6. I mention the file below you can save .yaml
---
Parameters:
SSHKey:
Type: AWS::EC2::KeyPair::KeyName
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Resources:
MyInstance:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: us-east-1a
ImageId: ami-009d6802948d06e52
InstanceType: t2.micro
KeyName: !Ref SSHKey
SecurityGroups:
- !Ref SSHSecurityGroup
# we install our web server with user data
UserData:
Fn::Base64: |
#!/bin/bash -xe
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "Hello World from user data" > /var/www/html/index.html
# our EC2 security group
SSHSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SSH and HTTP
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 22
IpProtocol: tcp
ToPort: 22
- CidrIp: 0.0.0.0/0
FromPort: 80
IpProtocol: tcp
ToPort: 80
7. Now save this file and upload to S3 and click on next
8. In next tab give the stack name as you want and give SSH keys, click on next
9. In next window i.e. “Configure Stack Window” don’t change anything and again click on next and Review the stack and create stack button or submit the stack.
10. Now you see your stack in progress
11. If you want to see stack progress you click on Events option and refresh it still shows “stack creation completed”
12. In Resources tab you check as per you mention the service is created or not with their option
13. Here you will see your EC2 Instance deployed successfully with SG you, now you can click on “Instance ID” copy the “Public Ip” and hit on browser you will see your message pop up which we written in html language.
14. You can see CloudFormation successfully craeted stack.