Skip to content

Instantly share code, notes, and snippets.

@devops-school
Created October 4, 2019 05:19
Show Gist options
  • Save devops-school/9e5f55626d7fd09f7b72bcb6b0508630 to your computer and use it in GitHub Desktop.
Save devops-school/9e5f55626d7fd09f7b72bcb6b0508630 to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "EC2-SecurityGroup-ElasticIP",
"Parameters": {
"VPC": {
"Description": "The default VPC",
"Type": "AWS::EC2::VPC::Id"
},
"Subnet": {
"Description": "A public subnet of VPC.",
"Type": "AWS::EC2::Subnet::Id"
},
"KeyPair": {
"Description": "A SSH key pair.",
"Type": "AWS::EC2::KeyPair::KeyName"
}
},
"Mappings": {
"RegionMap": {
"eu-west-1": {"AMI": "ami-bff32ccc"},
"ap-southeast-1": {"AMI": "ami-c9b572aa"},
"ap-southeast-2": {"AMI": "ami-48d38c2b"},
"eu-central-1": {"AMI": "ami-bc5b48d0"},
"ap-northeast-2": {"AMI": "ami-249b554a"},
"ap-northeast-1": {"AMI": "ami-383c1956"},
"us-east-1": {"AMI": "ami-60b6c60a"},
"sa-east-1": {"AMI": "ami-6817af04"},
"us-west-1": {"AMI": "ami-d5ea86b5"},
"us-west-2": {"AMI": "ami-f0091d91"}
}
},
"Resources": {
"EC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {"Fn::FindInMap": ["RegionMap", {"Ref": "AWS::Region"}, "AMI"]},
"InstanceType": "t2.nano",
"NetworkInterfaces": [{
"AssociatePublicIpAddress": "true",
"DeviceIndex": "0",
"GroupSet": [{"Ref": "SecurityGroup"}],
"SubnetId": {"Ref": "Subnet"}
}],
"Tags": [{
"Key": "Name",
"Value": "ssh-bastion-host"
}],
"KeyName": {"Ref": "KeyPair"}
}
},
"ElasticIP": {
"Type": "AWS::EC2::EIP",
"Properties": {
"InstanceId": {"Ref": "EC2Instance"},
"Domain": "vpc"
}
},
"SecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "ssh-bastion-host",
"VpcId": {"Ref": "VPC"},
"SecurityGroupIngress": [{
"CidrIp": "0.0.0.0/0",
"FromPort": 22,
"IpProtocol": "tcp",
"ToPort": 22
}]
}
}
},
"Outputs": {
"SSHBastionHost": {
"Description": "Public IP address of SSH bastion host.",
"Value": {"Ref": "ElasticIP"}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment