Skip to content

Instantly share code, notes, and snippets.

@christinedraper
Created March 5, 2015 19:29
Show Gist options
  • Save christinedraper/2edffff573c6fed17730 to your computer and use it in GitHub Desktop.
Save christinedraper/2edffff573c6fed17730 to your computer and use it in GitHub Desktop.
Simple CloudFormation template, generated topology.json and generated Chef provisioning recipes
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"elbappserverelb": {
"Type": "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties": {
"AvailabilityZones": [
"us-west-2c",
"us-west-2b",
"us-west-2a"
],
"Listeners": [
{
"InstancePort": "3001",
"LoadBalancerPort": "3001",
"Protocol": "HTTP",
"InstanceProtocol": "HTTP"
}
]
}
},
"asgappservergroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": [
"us-west-2c",
"us-west-2b",
"us-west-2a"
],
"Cooldown": "300",
"DesiredCapacity": "1",
"MaxSize": "2",
"MinSize": "1",
"HealthCheckGracePeriod": "0",
"HealthCheckType": "EC2",
"LaunchConfigurationName": {
"Ref": "lcappserverconfig"
},
"LoadBalancerNames": [
{
"Ref": "elbappserverelb"
}
]
}
},
"instancedbserver": {
"Type": "AWS::EC2::Instance",
"Properties": {
"DisableApiTermination": "FALSE",
"ImageId": "ami-f1ce8bc1",
"InstanceType": "t1.micro",
"KernelId": "aki-fc8f11cc",
"KeyName": "test1_aws",
"Monitoring": "false",
"Tags": [
{
"Key": "Name",
"Value": "dbserver"
}
],
"NetworkInterfaces": [
{
"DeleteOnTermination": "true",
"DeviceIndex": 0,
"AssociatePublicIpAddress": "true"
}
]
}
},
"lcappserverconfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": "ami-9f3015af",
"InstanceType": "t1.micro",
"InstanceMonitoring": "true"
}
}
},
"Description": "Autoscaling cluster with ELB"
}
{
"nodes": [
{
"name": "asgappservergroup",
"provisioning": {
"machine_options": {
"bootstrap_options": {
"image_id": "ami-9f3015af",
"instance_type": "t1.micro",
"instance_monitoring": "true"
}
},
"auto_scaling": {
"availability_zones": [
"us-west-2c",
"us-west-2b",
"us-west-2a"
],
"cooldown": 300,
"desired_capacity": 1,
"max_size": 2,
"min_size": 1,
"health_check_grace_period": 0,
"health_check_type": "EC2",
"load_balancer_names": [
{
"Ref": "elbappserverelb"
}
],
"load_balancers": [
"elbappserverelb"
]
}
}
},
{
"name": "instancedbserver",
"provisioning": {
"machine_options": {
"bootstrap_options": {
"disable_api_termination": false,
"image_id": "ami-f1ce8bc1",
"instance_type": "t1.micro",
"kernel_id": "aki-fc8f11cc",
"key_name": "test1_aws",
"monitoring_enabled": false
}
},
"tags": [
{
"key": "Name",
"value": "dbserver"
}
],
"network_interfaces": [
{
"delete_on_termination": true,
"device_index": 0,
"associate_public_ip_address": "true"
}
]
}
}
],
"services": [
{
"name": "elbappserverelb",
"type": "load_balancer",
"provisioning": {
"load_balancer_options": {
"availability_zones": [
"us-west-2c",
"us-west-2b",
"us-west-2a"
],
"listeners": [
{
"instance_port": 3001,
"protocol": "HTTP",
"instance_protocol": "HTTP",
"port": 3001
}
]
}
}
}
],
"network": [
],
"provisioning": {
"driver_url": "aws",
"machine_options": {
}
},
"name": "ai-autoscaling"
}
require 'chef/provisioning/aws_driver'
with_driver('aws')
with_machine_options({})
load_balancer "elbappserverelb" do
load_balancer_options({:availability_zones=>["us-west-2c", "us-west-2b", "us-west-2a"], :listeners=>[{:instance_port=>3001, :protocol=>"HTTP", :instance_protocol=>"HTTP", :port=>3001}]})
end
aws_launch_config "asgappservergroup_config" do
image "ami-9f3015af"
instance_type "t1.micro"
end
aws_auto_scaling_group "asgappservergroup_group" do
launch_config 'asgappservergroup_config'
max_size(2)
min_size(1)
desired_capacity(1)
load_balancers(["elbappserverelb"])
end
machine "instancedbserver" do
add_machine_options({:bootstrap_options=>{:disable_api_termination=>false, :image_id=>"ami-f1ce8bc1", :instance_type=>"t1.micro", :kernel_id=>"aki-fc8f11cc", :key_name=>"test1_aws", :monitoring_enabled=>false}})
end
require 'chef/provisioning/aws_driver'
with_driver('aws')
with_machine_options({})
machine instancedbserver do
action :destroy
end
aws_auto_scaling_group asgappservergroup_group do
action :delete
end
aws_launch_config asgappservergroup_config do
action :delete
end
load_balancer elbappserverelb do
action :destroy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment