From f389974cdba0051efb069a02b9567f1bc7be8229 Mon Sep 17 00:00:00 2001 From: minakshi <121312313+min5741@users.noreply.github.com> Date: Sun, 10 Nov 2024 21:03:45 +0530 Subject: [PATCH] ec2 instance.yml --- ec2 instance.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 ec2 instance.yml diff --git a/ec2 instance.yml b/ec2 instance.yml new file mode 100644 index 00000000..2bff6fb1 --- /dev/null +++ b/ec2 instance.yml @@ -0,0 +1,55 @@ +AWS TemplateFormatVersion: +'2010-09-09' +Description: CloudFormation template to provision EC2 instances for hosting an application + +Parameters: + Instance type: + Description: EC2 instance types + Type: String + Default: t2.micro + Allowed values: + :t2.micro + :t2.small + :t2.medium + ConstantDescription: Must be a valid EC2 instance type + + Key name: + Description: Name of an existing EC2 key pair to enable SSH access to the instances + Type: AWS::EC2::KeyPair::Keyname + + Resources: + InstanceSecurityGroup: + Type: AWS::EC2::SecurityGroup + Properties: + Group Description: Enable SSH and HTTP access + VpcId: + SecurityGroupIngress: + IpProtocol: tcp + FromPort: 22 + ToPort: 22 + CidrIp:0.0.0.0/0 + MyEC2Instance: + Type: AWS::EC2::Instance + Properties: + InstanceType: + KeyName: + ImageId:ami-0c5551bh4bnh + SecurityGroupIds: + InstanceSecurityGroup + UserData: + Fn::Base64: | + #!/bin/bash + yum update-y + yum install-y httpd + systemctl start httpd + systemctl enable httpd + echo"

Hello from EC2!

">/var/www/html/index.html + Outputs: + InstancePublicIp: + Description:Public Ip of the EC2 INSTANCE + Value:MyEC2Instance.PublicIp + + InstanceId: + Description:InstanceID OF THE ec2 instance + Value:MyEC2Instance +