================= Cloud Formation ================= => Cloud Formation service is used to provision infrastructure in AWS Cloud. => Cloud Formation works based on 'Infrastructure as a code' (IAAC) => Cloud Formation supports JSON and YML configurations Note: If we create infrastructure manually it takes lot of time and it is error prone. => If we design cloud formation template to create Infrasture then we can re-use that template multiple times. Note: Cloud Formation service works only in AWS Cloud. Note: The alternate for 'Cloud Formation' service is 'TERRAFORM' tool. => Terraform works with almost all cloud platforms available in the market. ============================================== Creating EC2 instance using Cloud Formation ============================================== => Go to AWS Management Console and Navigate to 'Cloud Formation' => Click on Create Stack and upload below Template File ---------------------------- Ec2 - creation - using - yml - file ------------------------- Description: Ashok IT - Build Linux Web Server Parameters: LatestAmiId: Description: AMI Linux EC2 Type: 'AWS::SSM::Parameter::Value' Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2' Resources: webserver1: Type: AWS::EC2::Instance Properties: InstanceType: "t2.micro" ImageId: !Ref LatestAmiId SecurityGroupIds: - !Ref WebserverSecurityGroup Tags: - Key: Name Value: webserver1 UserData: Fn::Base64: !Sub | #!/bin/bash -xe yum update -y yum install httpd -y service httpd start chkconfig httpd on cd /var/www/html echo "
" >> index.html echo "

Ashok IT EC2 Linux Demo

" >>index.html WebserverSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Enable Port 80 Tags: - Key: Name Value: webserver-sg SecurityGroupIngress: - IpProtocol: tcp FromPort: 80 ToPort: 80 CidrIp: 0.0.0.0/0 ------------------------------------------------------------------------ => Verify EC2 dashboard, we can see EC2 instance created => Access EC2 VM public in browser. =======================================================================