Skip to content

Instantly share code, notes, and snippets.

@vinhlee95
Created June 8, 2020 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinhlee95/d125be62a3228cec8c60d5578287a050 to your computer and use it in GitHub Desktop.
Save vinhlee95/d125be62a3228cec8c60d5578287a050 to your computer and use it in GitHub Desktop.
Resources:
MyInstance:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: "eu-north-1a"
ImageId: "ami-0c5254b956817b326"
InstanceType: "t3.micro"
KeyName: "ec2-general"
SecurityGroups:
- !Ref HTTPSecurityGroup
- !Ref SSHSecurityGroup
# Elastic IP for the instance
MyEIP:
Type: AWS::EC2::EIP
Properties:
InstanceId: !Ref MyInstance
SSHSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: SSHSecurityGroupStack
GroupDescription: Enable SSH access to instances via port 22
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 22
IpProtocol: tcp
ToPort: 22
HTTPSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: EC2CFHTTPGroup
GroupDescription: Allow HTTP traffics to instance in port 80
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 80
IpProtocol: tcp
ToPort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment