Skip to content

Instantly share code, notes, and snippets.

@SteveHoggNZ
Created November 30, 2016 21:58
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 SteveHoggNZ/4cc9e5d60fe546ffbd73870379fb5f64 to your computer and use it in GitHub Desktop.
Save SteveHoggNZ/4cc9e5d60fe546ffbd73870379fb5f64 to your computer and use it in GitHub Desktop.
CloudFormation / CreationPolicy / Minimal EC2 example
{
"Resources": {
"SSHServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"VpcId" : "vpc-fdcfd098",
"GroupDescription" : "Allow SSH access",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "<REDACTED>/32"}
]
}
},
"MyEC2": {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : "ami-db704cb8",
"KeyName" : "<REDACTED>",
"InstanceType" : "t2.micro",
"NetworkInterfaces" : [ {
"AssociatePublicIpAddress" : "true",
"DeviceIndex" : "0",
"GroupSet" : [ {"Ref" : "SSHServerSecurityGroup"} ],
"SubnetId" : "subnet-eccc6988"
} ],
},
"CreationPolicy": {
"ResourceSignal": {
"Count": 1,
"Timeout": "PT10M"
}
}
},
"MyTestSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"DependsOn" : "MyEC2",
"Properties" : {
"VpcId" : "vpc-fdcfd098",
"GroupDescription" : "A test security group",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"}
]
}
}
},
"Outputs" : {
"PublicIp" : {
"Value" : { "Fn::GetAtt" : [ "MyEC2", "PublicIp" ] },
"Description" : "The instance's public IP"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment