Skip to content

Instantly share code, notes, and snippets.

@syguer
Created February 4, 2014 01:26
Show Gist options
  • Save syguer/8795851 to your computer and use it in GitHub Desktop.
Save syguer/8795851 to your computer and use it in GitHub Desktop.
How to Control ELB with aws-sdk
require 'aws-sdk'
AWS.config(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY, :ec2_endpoint => REGION, :elb_endpoint => ELB_REGION)
@elb_client = AWS::ELB.new().client
# show description
@elb_client.describe_load_balancers({load_balancer_names: ["ELB_NAME"]})
# get a lb
lb = AWS::ELB.new.load_balancers["elb-test"]
#get listeners
listeners = lb.listeners
# create new listener
listeners.create(
:port => 8000,
:protocol => :tcp, # or :HTTP(s),:SSL
:instance_port => 8000,
:instance_protocol => :tcp # or :HTTP(s),:SSL
)
#set policy
listeners["8000"].policy = :POLICY_NAME
# delete a listener
listeners["8000"].delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment