Parameters: MyKeyPair: Description: Select the Key Pair you wish to use for these instances. Type: AWS::EC2::KeyPair::KeyName # Optional, but handy Default: MyDefaultKeyPair Resources: # Define the Security Group MySecurityGroupId: Type: AWS::EC2::SecurityGroup Properties: GroupName: My Security Group Name GroupDescription: My Security Group Description SecurityGroupIngress: - IpProtocol: icmp FromPort: -1 ToPort: -1 CidrIp: 0.0.0.0/0 - IpProtocol: tcp FromPort: 22 ToPort: 22 CidrIp: 0.0.0.0/0 - IpProtocol: tcp FromPort: 80 ToPort: 80 CidrIp: 0.0.0.0/0 Tags: - Key: Name Value: My CF Security Group # Define the EC2 Instance MyEc2Instance: Type: AWS::EC2::Instance Properties: ImageId: ami-710e2414 InstanceType: t2.micro # Optional, but required if you want to actually access it. KeyName: !Ref MyKeyPair # Use the Security Group created above SecurityGroups: - !Ref MySecurityGroupId Tags: - Key: Name Value: My EC2 Instance