Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit d014182

Browse files
committed
Add listener.ssl_certificate_id support to AWS ELB (@jpadvo [hashicorpGH-176])
2 parents 95f43d8 + 8d97c36 commit d014182

6 files changed

Lines changed: 40 additions & 3 deletions

File tree

builtin/providers/aws/resource_aws_elb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ func resource_aws_elb_validation() *config.Validator {
353353
},
354354
Optional: []string{
355355
"instances.*",
356+
"listener.*.ssl_certificate_id",
356357
"internal",
357358
"availability_zones.*",
358359
"security_groups.*",

builtin/providers/aws/resource_aws_elb_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package aws
22

33
import (
44
"fmt"
5+
"os"
56
"reflect"
67
"testing"
78

@@ -12,6 +13,7 @@ import (
1213

1314
func TestAccAWSELB_basic(t *testing.T) {
1415
var conf elb.LoadBalancer
16+
ssl_certificate_id := os.Getenv("AWS_SSL_CERTIFICATE_ID")
1517

1618
resource.Test(t, resource.TestCase{
1719
PreCheck: func() { testAccPreCheck(t) },
@@ -35,6 +37,8 @@ func TestAccAWSELB_basic(t *testing.T) {
3537
"aws_elb.bar", "listener.0.instance_port", "8000"),
3638
resource.TestCheckResourceAttr(
3739
"aws_elb.bar", "listener.0.instance_protocol", "http"),
40+
resource.TestCheckResourceAttr(
41+
"aws_elb.bar", "listener.0.ssl_certificate_id", ssl_certificate_id),
3842
resource.TestCheckResourceAttr(
3943
"aws_elb.bar", "listener.0.lb_port", "80"),
4044
resource.TestCheckResourceAttr(
@@ -277,6 +281,21 @@ resource "aws_instance" "foo" {
277281
}
278282
`
279283

284+
const testAccAWSELBConfigListenerSSLCertificateId = `
285+
resource "aws_elb" "bar" {
286+
name = "foobar-terraform-test"
287+
availability_zones = ["us-west-2a"]
288+
289+
listener {
290+
instance_port = 8000
291+
instance_protocol = "http"
292+
ssl_certificate_id = "%s"
293+
lb_port = 443
294+
lb_protocol = "https"
295+
}
296+
}
297+
`
298+
280299
const testAccAWSELBConfigHealthCheck = `
281300
resource "aws_elb" "bar" {
282301
name = "foobar-terraform-test"

builtin/providers/aws/resource_provider_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ func testAccPreCheck(t *testing.T) {
9292
log.Println("[INFO] Test: Using us-west-2 as test region")
9393
os.Setenv("AWS_REGION", "us-west-2")
9494
}
95+
if v := os.Getenv("AWS_SSL_CERTIFICATE_ID"); v == "" {
96+
t.Fatal("AWS_SSL_CERTIFICATE_ID must be set for acceptance tests")
97+
}
9598
}

builtin/providers/aws/structure.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ func expandListeners(configured []interface{}) ([]elb.Listener, error) {
3333
Protocol: newL["lb_protocol"].(string),
3434
}
3535

36+
if attr, ok := newL["ssl_certificate_id"].(string); ok {
37+
l.SSLCertificateId = attr
38+
}
39+
40+
3641
listeners = append(listeners, l)
3742
}
3843

builtin/providers/aws/structure_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ func Test_expandIPPerms(t *testing.T) {
7070
},
7171
},
7272
ec2.IPPerm{
73-
Protocol: "icmp",
74-
FromPort: 1,
75-
ToPort: -1,
73+
Protocol: "icmp",
74+
FromPort: 1,
75+
ToPort: -1,
7676
SourceGroups: []ec2.UserSecurityGroup{
7777
ec2.UserSecurityGroup{
7878
Id: "foo",

website/source/docs/providers/aws/r/elb.html.markdown

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ resource "aws_elb" "bar" {
2323
lb_protocol = "http"
2424
}
2525
26+
listener {
27+
instance_port = 8000
28+
instance_protocol = "http"
29+
lb_port = 443
30+
lb_protocol = "https"
31+
ssl_certificate_id = "arn:aws:iam::123456789012:server-certificate/certName"
32+
}
33+
2634
health_check {
2735
healthy_threshold = 2
2836
unhealthy_threshold = 2
@@ -54,6 +62,7 @@ Listeners support the following:
5462
* `instance_protocol` - (Required) The the protocol to use to the instance.
5563
* `lb_port` - (Required) The port to listen on for the load balancer
5664
* `lb_protocol` - (Required) The protocol to listen on.
65+
* `ssl_certificate_id` - (Optional) The id of an SSL certificate you have uploaded to AWS IAM.
5766

5867
Health Check supports the following:
5968

0 commit comments

Comments
 (0)