Skip to content

Commit

Permalink
Merge pull request #449 from keen99/pr-fix_elb_cert_update
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-ball committed Aug 8, 2016
2 parents e4d35db + 51b4cb2 commit a348e4f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/chef/provisioning/aws_driver/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ def allocate_load_balancer(action_handler, lb_spec, lb_options, machine_specs)
elsif ! server_certificate_eql?(listener.server_certificate,
server_cert_from_spec(desired_listener))
# Server certificate is mutable - if no immutable changes required a full recreate, update cert
perform_action.call(" update server certificate from #{listener.server_certificate} to #{desired_listener[:server_certificate]}") do
listener.server_certificate = desired_listener[:server_certificate]
perform_action.call(" update server certificate from #{listener.server_certificate} to #{server_cert_from_spec(desired_listener)}") do
listener.server_certificate = server_cert_from_spec(desired_listener)
end
end

Expand All @@ -356,7 +356,7 @@ def allocate_load_balancer(action_handler, lb_spec, lb_options, machine_specs)
updates << " set protocol to #{listener[:protocol].inspect}"
updates << " set instance port to #{listener[:instance_port].inspect}"
updates << " set instance protocol to #{listener[:instance_protocol].inspect}"
updates << " set server certificate to #{listener[:server_certificate]}" if listener[:server_certificate]
updates << " set server certificate to #{server_cert_from_spec(listener)}" if server_cert_from_spec(listener)
perform_action.call(updates) do
actual_elb.listeners.create(listener)
end
Expand Down
28 changes: 27 additions & 1 deletion spec/integration/load_balancer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
recursive_delete true
end

cert_string = "-----BEGIN CERTIFICATE-----\nMIIDejCCAmICCQCpupMy/LKfLTANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHU2VhdHRsZTENMAsGA1UE\nChMEQ2hlZjEMMAoGA1UECxMDRGV2MQ4wDAYDVQQDEwVUeWxlcjEcMBoGCSqGSIb3\nD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VXlsidVNN2tW/50\n8kEaPHPVeP6Trt2kPtpQnhDcuQXbPmOgPBIY2j6nu/Go25e8eICkfhsCgYEA23iy\n8Og1SWZlV5b3ZFyolZiZ9kp0cwyXUGWxUZyw33gBmK6BFkscflI1vfNutxnTDjNl\nALLRoAeIApvXTMFOMUPJsDk90pO7rdlfLznU27lKPyCDkvDGmjCvGGDXrnvi+cc3\ngB3ERfrLJCMoMk9lyg7/KEzzsIjvtTRO79atCLcCgYAGT/+wI2YDj0KVU1wRI2An\nJsTYk3H8Jsjcvf66faEmq98yLX7xQIG3q9xZPF0wNeiBgmOikMA3wI9pVO5ClBaD\nb8gUZtVcKc9GVIbrhPbpb2ckasdzh64rBxGVE/w0HIdjXvpCfVTu2ke3N3ThKp3q\nExq8zjd3ijS6DTnn9orTkwKBgQCxVwpgl4HXWaIx8I7ezfB7UN+3n9oQzO/HyyRI\n6fAR4oqHsRolxXO0rwE2B+pCkd907hqDQfsY8Hz6fqquHtTsAfaLKvXFnhJdG/RJ\n2NUi5soT0FYA+gXAue4CKN6e4wQ5CLzUDTl3wns7LB1i6b06VHvhOK0AzOXE6guO\nyUzwaQKBgDCrGz6IrxEUWl6C14xNNRZBvYTY9oCQpUnup1gMxATJZm4KelKvtKz2\nU1MXpc1i395e+E+tjNAQg0JcBmwkHOMl8c/oAESWPxi11ezalGtUXjIgjBkqqNUE\n/uFqRpNFGwI09JolIqhBTgPWFq6MuuPDJ9IIGJZDQoGEBKmu0k2r\n-----END RSA PRIVATE KEY-----"

aws_server_certificate "load_balancer_cert" do
certificate_body cert_string
private_key private_key_string
end

aws_server_certificate "load_balancer_cert_2" do
certificate_body cert_string
private_key private_key_string
end

it "creates a load_balancer with the maximum attributes" do
expect_recipe {
load_balancer 'test-load-balancer' do
Expand Down Expand Up @@ -173,6 +178,13 @@
:protocol => :http,
:instance_port => 80,
:instance_protocol => :http,
},
{
:port => 8443,
:protocol => :https,
:instance_port => 80,
:instance_protocol => :http,
:ssl_certificate_id => load_balancer_cert.aws_object.arn
}],
subnets: ["test_public_subnet"],
security_groups: ["test_security_group"],
Expand Down Expand Up @@ -219,6 +231,13 @@
:instance_port => 8080,
:instance_protocol => :http,
:ssl_certificate_id => load_balancer_cert.aws_object.arn
},
{
:port => 8443,
:protocol => :https,
:instance_port => 80,
:instance_protocol => :http,
:ssl_certificate_id => load_balancer_cert_2.aws_object.arn
}],
subnets: ["test_public_subnet2"],
security_groups: ["test_security_group2"],
Expand Down Expand Up @@ -262,6 +281,13 @@
:instance_port => 8080,
:instance_protocol => :http,
:server_certificate => {arn: load_balancer_cert.aws_object.arn}
},
{
:port => 8443,
:protocol => :https,
:instance_port => 80,
:instance_protocol => :http,
:server_certificate => {arn: load_balancer_cert_2.aws_object.arn}
}],
subnets: [test_public_subnet2.aws_object],
security_groups: [test_security_group2.aws_object],
Expand Down

0 comments on commit a348e4f

Please sign in to comment.