Skip to content

Instantly share code, notes, and snippets.

@rnaveiras
Created November 10, 2014 14:02
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 rnaveiras/afe588bed79a6c3ba94c to your computer and use it in GitHub Desktop.
Save rnaveiras/afe588bed79a6c3ba94c to your computer and use it in GitHub Desktop.
require 'aws-sdk'
AWS.config(:credential_provider => AWS::Core::CredentialProviders::SharedCredentialFileProvider.new)
aws = AWS.regions['eu-west-1']
lc = aws.auto_scaling.launch_configurations
launch_config = lc.create('staging-loadbalancer', 'ami-XXXXX', 'm1.small', {
detailed_instance_monitoring: true,
key_pair: 'wadus',
security_groups: ['example'],
user_data: File.read('./combined-cloudinit.yml'),
iam_instance_profile: 'loadbalancer'})
groups = aws.auto_scaling.groups
group = groups.create('staging-loadbalancer',
launch_configuration: launch_config,
availability_zones: %w(eu-west-1b),
min_size: 1,
max_size: 1,
desired_capacity: 1,
health_check_grace_period: 300,
health_check_type: :ec2,
tags: [{ key: 'Environment', value: 'staging', propagate_at_launch: true },
{ key: 'Roles', value: 'loadbalancer', propagate_at_launch: true }]
)
# group.notification_configurations.create(topic: 'arn:aws:sns:eu-west-1:051915741463:AWS-notifications')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment