create_ec2_instance with keypair and allow ssh
from anywhere
This commit is contained in:
34
01_ec2.yaml
34
01_ec2.yaml
@@ -1,9 +1,37 @@
|
|||||||
AWSTemplateFormatVersion: 2010-09-09
|
AWSTemplateFormatVersion: 2010-09-09
|
||||||
Description: Part 1 - Build a webapp stack with CloudFormation
|
Description: Building EC2 Instance using CloudFormation
|
||||||
|
|
||||||
Resources:
|
Resources:
|
||||||
WebAppInstance:
|
|
||||||
Type: AWS::EC2::Instance
|
DefaultSecurityGroupIngress:
|
||||||
|
Type: 'AWS::EC2::SecurityGroupIngress'
|
||||||
|
Properties:
|
||||||
|
GroupId: sg-04979a7901ebe5c37
|
||||||
|
IpProtocol: tcp
|
||||||
|
FromPort: 22
|
||||||
|
ToPort: 22
|
||||||
|
CidrIp: 0.0.0.0/0
|
||||||
|
|
||||||
|
KeyPair:
|
||||||
|
Type: 'AWS::EC2::KeyPair::KeyName'
|
||||||
|
Properties:
|
||||||
|
KeyName: existing-key-pair-name
|
||||||
|
|
||||||
|
ChoseEC2:
|
||||||
|
Type: 'AWS::EC2::Instance'
|
||||||
|
DependsOn: KeyPair
|
||||||
Properties:
|
Properties:
|
||||||
ImageId: ami-0df8c184d5f6ae949
|
ImageId: ami-0df8c184d5f6ae949
|
||||||
InstanceType: t2.micro
|
InstanceType: t2.micro
|
||||||
|
KeyName: !Ref KeyPair
|
||||||
|
SecurityGroupIds:
|
||||||
|
- sg-04979a7901ebe5c37
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
LabInstanceId:
|
||||||
|
Description: Instance Id
|
||||||
|
Value: !Ref ChoseEC2
|
||||||
|
|
||||||
|
LabInstancePublicIP:
|
||||||
|
Description: Public IP address of the instance
|
||||||
|
Value: !GetAtt ChoseEC2.PublicIp
|
||||||
|
Reference in New Issue
Block a user