Skip to content

Instantly share code, notes, and snippets.

@mryoshio
Created January 27, 2015 07:27
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 mryoshio/6a3fddda4de86d58c7e9 to your computer and use it in GitHub Desktop.
Save mryoshio/6a3fddda4de86d58c7e9 to your computer and use it in GitHub Desktop.
Update ELB SSL Certificate
require 'aws-sdk'
NEW_CERT_NAME = 'xxx'
REGIONS = AWS::EC2.new.regions.map(&:name)
NEW_CERT = AWS::IAM.new.server_certificates[NEW_CERT_NAME]
REGIONS.each do |r|
puts "# region: #{r}"
elb = AWS::ELB.new(region: r)
elb.load_balancers.each do |lb|
puts "## #{lb.name} (#{lb.dns_name})"
lb.listeners.each do |l|
next unless l.protocol == :https || l.server_certificate
puts "- [begin to udpate ELB certificate] at #{Time.now}"
l.server_certificate = NEW_CERT
puts "- [finished] at #{Time.now}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment