github.com/i0n/terraform@v0.4.3-0.20150506151324-010a39a58ec1/builtin/providers/aws/resource_aws_elb_test.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 "os" 6 "reflect" 7 "sort" 8 "testing" 9 10 "github.com/awslabs/aws-sdk-go/aws" 11 "github.com/awslabs/aws-sdk-go/service/elb" 12 "github.com/hashicorp/terraform/helper/resource" 13 "github.com/hashicorp/terraform/terraform" 14 ) 15 16 func TestAccAWSELB_basic(t *testing.T) { 17 var conf elb.LoadBalancerDescription 18 ssl_certificate_id := os.Getenv("AWS_SSL_CERTIFICATE_ID") 19 20 resource.Test(t, resource.TestCase{ 21 PreCheck: func() { testAccPreCheck(t) }, 22 Providers: testAccProviders, 23 CheckDestroy: testAccCheckAWSELBDestroy, 24 Steps: []resource.TestStep{ 25 resource.TestStep{ 26 Config: testAccAWSELBConfig, 27 Check: resource.ComposeTestCheckFunc( 28 testAccCheckAWSELBExists("aws_elb.bar", &conf), 29 testAccCheckAWSELBAttributes(&conf), 30 resource.TestCheckResourceAttr( 31 "aws_elb.bar", "name", "foobar-terraform-test"), 32 resource.TestCheckResourceAttr( 33 "aws_elb.bar", "availability_zones.2487133097", "us-west-2a"), 34 resource.TestCheckResourceAttr( 35 "aws_elb.bar", "availability_zones.221770259", "us-west-2b"), 36 resource.TestCheckResourceAttr( 37 "aws_elb.bar", "availability_zones.2050015877", "us-west-2c"), 38 resource.TestCheckResourceAttr( 39 "aws_elb.bar", "listener.206423021.instance_port", "8000"), 40 resource.TestCheckResourceAttr( 41 "aws_elb.bar", "listener.206423021.instance_protocol", "http"), 42 resource.TestCheckResourceAttr( 43 "aws_elb.bar", "listener.206423021.ssl_certificate_id", ssl_certificate_id), 44 resource.TestCheckResourceAttr( 45 "aws_elb.bar", "listener.206423021.lb_port", "80"), 46 resource.TestCheckResourceAttr( 47 "aws_elb.bar", "listener.206423021.lb_protocol", "http"), 48 resource.TestCheckResourceAttr( 49 "aws_elb.bar", "cross_zone_load_balancing", "true"), 50 ), 51 }, 52 }, 53 }) 54 } 55 56 func TestAccAWSELB_tags(t *testing.T) { 57 var conf elb.LoadBalancerDescription 58 var td elb.TagDescription 59 60 resource.Test(t, resource.TestCase{ 61 PreCheck: func() { testAccPreCheck(t) }, 62 Providers: testAccProviders, 63 CheckDestroy: testAccCheckAWSELBDestroy, 64 Steps: []resource.TestStep{ 65 resource.TestStep{ 66 Config: testAccAWSELBConfig, 67 Check: resource.ComposeTestCheckFunc( 68 testAccCheckAWSELBExists("aws_elb.bar", &conf), 69 testAccCheckAWSELBAttributes(&conf), 70 resource.TestCheckResourceAttr( 71 "aws_elb.bar", "name", "foobar-terraform-test"), 72 testAccLoadTags(&conf, &td), 73 testAccCheckELBTags(&td.Tags, "bar", "baz"), 74 ), 75 }, 76 77 resource.TestStep{ 78 Config: testAccAWSELBConfig_TagUpdate, 79 Check: resource.ComposeTestCheckFunc( 80 testAccCheckAWSELBExists("aws_elb.bar", &conf), 81 testAccCheckAWSELBAttributes(&conf), 82 resource.TestCheckResourceAttr( 83 "aws_elb.bar", "name", "foobar-terraform-test"), 84 testAccLoadTags(&conf, &td), 85 testAccCheckELBTags(&td.Tags, "foo", "bar"), 86 testAccCheckELBTags(&td.Tags, "new", "type"), 87 ), 88 }, 89 }, 90 }) 91 } 92 93 func testAccLoadTags(conf *elb.LoadBalancerDescription, td *elb.TagDescription) resource.TestCheckFunc { 94 return func(s *terraform.State) error { 95 conn := testAccProvider.Meta().(*AWSClient).elbconn 96 97 describe, err := conn.DescribeTags(&elb.DescribeTagsInput{ 98 LoadBalancerNames: []*string{conf.LoadBalancerName}, 99 }) 100 101 if err != nil { 102 return err 103 } 104 if len(describe.TagDescriptions) > 0 { 105 *td = *describe.TagDescriptions[0] 106 } 107 return nil 108 } 109 } 110 111 func TestAccAWSELB_InstanceAttaching(t *testing.T) { 112 var conf elb.LoadBalancerDescription 113 114 testCheckInstanceAttached := func(count int) resource.TestCheckFunc { 115 return func(*terraform.State) error { 116 if len(conf.Instances) != count { 117 return fmt.Errorf("instance count does not match") 118 } 119 return nil 120 } 121 } 122 123 resource.Test(t, resource.TestCase{ 124 PreCheck: func() { testAccPreCheck(t) }, 125 Providers: testAccProviders, 126 CheckDestroy: testAccCheckAWSELBDestroy, 127 Steps: []resource.TestStep{ 128 resource.TestStep{ 129 Config: testAccAWSELBConfig, 130 Check: resource.ComposeTestCheckFunc( 131 testAccCheckAWSELBExists("aws_elb.bar", &conf), 132 testAccCheckAWSELBAttributes(&conf), 133 ), 134 }, 135 136 resource.TestStep{ 137 Config: testAccAWSELBConfigNewInstance, 138 Check: resource.ComposeTestCheckFunc( 139 testAccCheckAWSELBExists("aws_elb.bar", &conf), 140 testCheckInstanceAttached(1), 141 ), 142 }, 143 }, 144 }) 145 } 146 147 func TestAccAWSELBUpdate_Listener(t *testing.T) { 148 var conf elb.LoadBalancerDescription 149 150 resource.Test(t, resource.TestCase{ 151 PreCheck: func() { testAccPreCheck(t) }, 152 Providers: testAccProviders, 153 CheckDestroy: testAccCheckAWSELBDestroy, 154 Steps: []resource.TestStep{ 155 resource.TestStep{ 156 Config: testAccAWSELBConfig, 157 Check: resource.ComposeTestCheckFunc( 158 testAccCheckAWSELBExists("aws_elb.bar", &conf), 159 testAccCheckAWSELBAttributes(&conf), 160 resource.TestCheckResourceAttr( 161 "aws_elb.bar", "listener.206423021.instance_port", "8000"), 162 ), 163 }, 164 165 resource.TestStep{ 166 Config: testAccAWSELBConfigListener_update, 167 Check: resource.ComposeTestCheckFunc( 168 testAccCheckAWSELBExists("aws_elb.bar", &conf), 169 resource.TestCheckResourceAttr( 170 "aws_elb.bar", "listener.3931999347.instance_port", "8080"), 171 ), 172 }, 173 }, 174 }) 175 } 176 177 func TestAccAWSELB_HealthCheck(t *testing.T) { 178 var conf elb.LoadBalancerDescription 179 180 resource.Test(t, resource.TestCase{ 181 PreCheck: func() { testAccPreCheck(t) }, 182 Providers: testAccProviders, 183 CheckDestroy: testAccCheckAWSELBDestroy, 184 Steps: []resource.TestStep{ 185 resource.TestStep{ 186 Config: testAccAWSELBConfigHealthCheck, 187 Check: resource.ComposeTestCheckFunc( 188 testAccCheckAWSELBExists("aws_elb.bar", &conf), 189 testAccCheckAWSELBAttributesHealthCheck(&conf), 190 resource.TestCheckResourceAttr( 191 "aws_elb.bar", "health_check.3484319807.healthy_threshold", "5"), 192 resource.TestCheckResourceAttr( 193 "aws_elb.bar", "health_check.3484319807.unhealthy_threshold", "5"), 194 resource.TestCheckResourceAttr( 195 "aws_elb.bar", "health_check.3484319807.target", "HTTP:8000/"), 196 resource.TestCheckResourceAttr( 197 "aws_elb.bar", "health_check.3484319807.timeout", "30"), 198 resource.TestCheckResourceAttr( 199 "aws_elb.bar", "health_check.3484319807.interval", "60"), 200 ), 201 }, 202 }, 203 }) 204 } 205 206 func TestAccAWSELBUpdate_HealthCheck(t *testing.T) { 207 resource.Test(t, resource.TestCase{ 208 PreCheck: func() { testAccPreCheck(t) }, 209 Providers: testAccProviders, 210 CheckDestroy: testAccCheckAWSELBDestroy, 211 Steps: []resource.TestStep{ 212 resource.TestStep{ 213 Config: testAccAWSELBConfigHealthCheck, 214 Check: resource.ComposeTestCheckFunc( 215 resource.TestCheckResourceAttr( 216 "aws_elb.bar", "health_check.3484319807.healthy_threshold", "5"), 217 ), 218 }, 219 resource.TestStep{ 220 Config: testAccAWSELBConfigHealthCheck_update, 221 Check: resource.ComposeTestCheckFunc( 222 resource.TestCheckResourceAttr( 223 "aws_elb.bar", "health_check.2648756019.healthy_threshold", "10"), 224 ), 225 }, 226 }, 227 }) 228 } 229 230 func TestAccAWSELB_Timeout(t *testing.T) { 231 var conf elb.LoadBalancerDescription 232 233 resource.Test(t, resource.TestCase{ 234 PreCheck: func() { testAccPreCheck(t) }, 235 Providers: testAccProviders, 236 CheckDestroy: testAccCheckAWSELBDestroy, 237 Steps: []resource.TestStep{ 238 resource.TestStep{ 239 Config: testAccAWSELBConfigIdleTimeout, 240 Check: resource.ComposeTestCheckFunc( 241 testAccCheckAWSELBExists("aws_elb.bar", &conf), 242 resource.TestCheckResourceAttr( 243 "aws_elb.bar", "idle_timeout", "200", 244 ), 245 ), 246 }, 247 }, 248 }) 249 } 250 251 func TestAccAWSELBUpdate_Timeout(t *testing.T) { 252 resource.Test(t, resource.TestCase{ 253 PreCheck: func() { testAccPreCheck(t) }, 254 Providers: testAccProviders, 255 CheckDestroy: testAccCheckAWSELBDestroy, 256 Steps: []resource.TestStep{ 257 resource.TestStep{ 258 Config: testAccAWSELBConfigIdleTimeout, 259 Check: resource.ComposeTestCheckFunc( 260 resource.TestCheckResourceAttr( 261 "aws_elb.bar", "idle_timeout", "200", 262 ), 263 ), 264 }, 265 resource.TestStep{ 266 Config: testAccAWSELBConfigIdleTimeout_update, 267 Check: resource.ComposeTestCheckFunc( 268 resource.TestCheckResourceAttr( 269 "aws_elb.bar", "idle_timeout", "400", 270 ), 271 ), 272 }, 273 }, 274 }) 275 } 276 277 func TestAccAWSELB_ConnectionDraining(t *testing.T) { 278 resource.Test(t, resource.TestCase{ 279 PreCheck: func() { testAccPreCheck(t) }, 280 Providers: testAccProviders, 281 CheckDestroy: testAccCheckAWSELBDestroy, 282 Steps: []resource.TestStep{ 283 resource.TestStep{ 284 Config: testAccAWSELBConfigConnectionDraining, 285 Check: resource.ComposeTestCheckFunc( 286 resource.TestCheckResourceAttr( 287 "aws_elb.bar", "connection_draining", "true", 288 ), 289 resource.TestCheckResourceAttr( 290 "aws_elb.bar", "connection_draining_timeout", "400", 291 ), 292 ), 293 }, 294 }, 295 }) 296 } 297 298 func TestAccAWSELBUpdate_ConnectionDraining(t *testing.T) { 299 resource.Test(t, resource.TestCase{ 300 PreCheck: func() { testAccPreCheck(t) }, 301 Providers: testAccProviders, 302 CheckDestroy: testAccCheckAWSELBDestroy, 303 Steps: []resource.TestStep{ 304 resource.TestStep{ 305 Config: testAccAWSELBConfigConnectionDraining, 306 Check: resource.ComposeTestCheckFunc( 307 resource.TestCheckResourceAttr( 308 "aws_elb.bar", "connection_draining", "true", 309 ), 310 resource.TestCheckResourceAttr( 311 "aws_elb.bar", "connection_draining_timeout", "400", 312 ), 313 ), 314 }, 315 resource.TestStep{ 316 Config: testAccAWSELBConfigConnectionDraining_update_timeout, 317 Check: resource.ComposeTestCheckFunc( 318 resource.TestCheckResourceAttr( 319 "aws_elb.bar", "connection_draining", "true", 320 ), 321 resource.TestCheckResourceAttr( 322 "aws_elb.bar", "connection_draining_timeout", "600", 323 ), 324 ), 325 }, 326 resource.TestStep{ 327 Config: testAccAWSELBConfigConnectionDraining_update_disable, 328 Check: resource.ComposeTestCheckFunc( 329 resource.TestCheckResourceAttr( 330 "aws_elb.bar", "connection_draining", "false", 331 ), 332 ), 333 }, 334 }, 335 }) 336 } 337 338 func TestAccAWSELB_SecurityGroups(t *testing.T) { 339 resource.Test(t, resource.TestCase{ 340 PreCheck: func() { testAccPreCheck(t) }, 341 Providers: testAccProviders, 342 CheckDestroy: testAccCheckAWSELBDestroy, 343 Steps: []resource.TestStep{ 344 resource.TestStep{ 345 Config: testAccAWSELBConfig, 346 Check: resource.ComposeTestCheckFunc( 347 resource.TestCheckResourceAttr( 348 "aws_elb.bar", "security_groups.#", "0", 349 ), 350 ), 351 }, 352 resource.TestStep{ 353 Config: testAccAWSELBConfigSecurityGroups, 354 Check: resource.ComposeTestCheckFunc( 355 resource.TestCheckResourceAttr( 356 "aws_elb.bar", "security_groups.#", "1", 357 ), 358 ), 359 }, 360 }, 361 }) 362 } 363 364 func testAccCheckAWSELBDestroy(s *terraform.State) error { 365 conn := testAccProvider.Meta().(*AWSClient).elbconn 366 367 for _, rs := range s.RootModule().Resources { 368 if rs.Type != "aws_elb" { 369 continue 370 } 371 372 describe, err := conn.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{ 373 LoadBalancerNames: []*string{aws.String(rs.Primary.ID)}, 374 }) 375 376 if err == nil { 377 if len(describe.LoadBalancerDescriptions) != 0 && 378 *describe.LoadBalancerDescriptions[0].LoadBalancerName == rs.Primary.ID { 379 return fmt.Errorf("ELB still exists") 380 } 381 } 382 383 // Verify the error 384 providerErr, ok := err.(aws.APIError) 385 if !ok { 386 return err 387 } 388 389 if providerErr.Code != "InvalidLoadBalancerName.NotFound" { 390 return fmt.Errorf("Unexpected error: %s", err) 391 } 392 } 393 394 return nil 395 } 396 397 func testAccCheckAWSELBAttributes(conf *elb.LoadBalancerDescription) resource.TestCheckFunc { 398 return func(s *terraform.State) error { 399 zones := []string{"us-west-2a", "us-west-2b", "us-west-2c"} 400 azs := make([]string, 0, len(conf.AvailabilityZones)) 401 for _, x := range conf.AvailabilityZones { 402 azs = append(azs, *x) 403 } 404 sort.StringSlice(azs).Sort() 405 if !reflect.DeepEqual(azs, zones) { 406 return fmt.Errorf("bad availability_zones") 407 } 408 409 if *conf.LoadBalancerName != "foobar-terraform-test" { 410 return fmt.Errorf("bad name") 411 } 412 413 l := elb.Listener{ 414 InstancePort: aws.Long(int64(8000)), 415 InstanceProtocol: aws.String("HTTP"), 416 LoadBalancerPort: aws.Long(int64(80)), 417 Protocol: aws.String("HTTP"), 418 } 419 420 if !reflect.DeepEqual(conf.ListenerDescriptions[0].Listener, &l) { 421 return fmt.Errorf( 422 "Got:\n\n%#v\n\nExpected:\n\n%#v\n", 423 conf.ListenerDescriptions[0].Listener, 424 l) 425 } 426 427 if *conf.DNSName == "" { 428 return fmt.Errorf("empty dns_name") 429 } 430 431 return nil 432 } 433 } 434 435 func testAccCheckAWSELBAttributesHealthCheck(conf *elb.LoadBalancerDescription) resource.TestCheckFunc { 436 return func(s *terraform.State) error { 437 zones := []string{"us-west-2a", "us-west-2b", "us-west-2c"} 438 azs := make([]string, 0, len(conf.AvailabilityZones)) 439 for _, x := range conf.AvailabilityZones { 440 azs = append(azs, *x) 441 } 442 sort.StringSlice(azs).Sort() 443 if !reflect.DeepEqual(azs, zones) { 444 return fmt.Errorf("bad availability_zones") 445 } 446 447 if *conf.LoadBalancerName != "foobar-terraform-test" { 448 return fmt.Errorf("bad name") 449 } 450 451 check := &elb.HealthCheck{ 452 Timeout: aws.Long(int64(30)), 453 UnhealthyThreshold: aws.Long(int64(5)), 454 HealthyThreshold: aws.Long(int64(5)), 455 Interval: aws.Long(int64(60)), 456 Target: aws.String("HTTP:8000/"), 457 } 458 459 if !reflect.DeepEqual(conf.HealthCheck, check) { 460 return fmt.Errorf( 461 "Got:\n\n%#v\n\nExpected:\n\n%#v\n", 462 conf.HealthCheck, 463 check) 464 } 465 466 if *conf.DNSName == "" { 467 return fmt.Errorf("empty dns_name") 468 } 469 470 return nil 471 } 472 } 473 474 func testAccCheckAWSELBExists(n string, res *elb.LoadBalancerDescription) resource.TestCheckFunc { 475 return func(s *terraform.State) error { 476 rs, ok := s.RootModule().Resources[n] 477 if !ok { 478 return fmt.Errorf("Not found: %s", n) 479 } 480 481 if rs.Primary.ID == "" { 482 return fmt.Errorf("No ELB ID is set") 483 } 484 485 conn := testAccProvider.Meta().(*AWSClient).elbconn 486 487 describe, err := conn.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{ 488 LoadBalancerNames: []*string{aws.String(rs.Primary.ID)}, 489 }) 490 491 if err != nil { 492 return err 493 } 494 495 if len(describe.LoadBalancerDescriptions) != 1 || 496 *describe.LoadBalancerDescriptions[0].LoadBalancerName != rs.Primary.ID { 497 return fmt.Errorf("ELB not found") 498 } 499 500 *res = *describe.LoadBalancerDescriptions[0] 501 502 return nil 503 } 504 } 505 506 const testAccAWSELBConfig = ` 507 resource "aws_elb" "bar" { 508 name = "foobar-terraform-test" 509 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 510 511 listener { 512 instance_port = 8000 513 instance_protocol = "http" 514 lb_port = 80 515 lb_protocol = "http" 516 } 517 518 tags { 519 bar = "baz" 520 } 521 522 cross_zone_load_balancing = true 523 } 524 ` 525 526 const testAccAWSELBConfig_TagUpdate = ` 527 resource "aws_elb" "bar" { 528 name = "foobar-terraform-test" 529 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 530 531 listener { 532 instance_port = 8000 533 instance_protocol = "http" 534 lb_port = 80 535 lb_protocol = "http" 536 } 537 538 tags { 539 foo = "bar" 540 new = "type" 541 } 542 543 cross_zone_load_balancing = true 544 } 545 ` 546 547 const testAccAWSELBConfigNewInstance = ` 548 resource "aws_elb" "bar" { 549 name = "foobar-terraform-test" 550 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 551 552 listener { 553 instance_port = 8000 554 instance_protocol = "http" 555 lb_port = 80 556 lb_protocol = "http" 557 } 558 559 instances = ["${aws_instance.foo.id}"] 560 } 561 562 resource "aws_instance" "foo" { 563 # us-west-2 564 ami = "ami-043a5034" 565 instance_type = "t1.micro" 566 } 567 ` 568 569 const testAccAWSELBConfigListenerSSLCertificateId = ` 570 resource "aws_elb" "bar" { 571 name = "foobar-terraform-test" 572 availability_zones = ["us-west-2a"] 573 574 listener { 575 instance_port = 8000 576 instance_protocol = "http" 577 ssl_certificate_id = "%s" 578 lb_port = 443 579 lb_protocol = "https" 580 } 581 } 582 ` 583 584 const testAccAWSELBConfigHealthCheck = ` 585 resource "aws_elb" "bar" { 586 name = "foobar-terraform-test" 587 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 588 589 listener { 590 instance_port = 8000 591 instance_protocol = "http" 592 lb_port = 80 593 lb_protocol = "http" 594 } 595 596 health_check { 597 healthy_threshold = 5 598 unhealthy_threshold = 5 599 target = "HTTP:8000/" 600 interval = 60 601 timeout = 30 602 } 603 } 604 ` 605 606 const testAccAWSELBConfigHealthCheck_update = ` 607 resource "aws_elb" "bar" { 608 name = "foobar-terraform-test" 609 availability_zones = ["us-west-2a"] 610 611 listener { 612 instance_port = 8000 613 instance_protocol = "http" 614 lb_port = 80 615 lb_protocol = "http" 616 } 617 618 health_check { 619 healthy_threshold = 10 620 unhealthy_threshold = 5 621 target = "HTTP:8000/" 622 interval = 60 623 timeout = 30 624 } 625 } 626 ` 627 628 const testAccAWSELBConfigListener_update = ` 629 resource "aws_elb" "bar" { 630 name = "foobar-terraform-test" 631 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 632 633 listener { 634 instance_port = 8080 635 instance_protocol = "http" 636 lb_port = 80 637 lb_protocol = "http" 638 } 639 } 640 ` 641 642 const testAccAWSELBConfigIdleTimeout = ` 643 resource "aws_elb" "bar" { 644 name = "foobar-terraform-test" 645 availability_zones = ["us-west-2a"] 646 647 listener { 648 instance_port = 8000 649 instance_protocol = "http" 650 lb_port = 80 651 lb_protocol = "http" 652 } 653 654 idle_timeout = 200 655 } 656 ` 657 658 const testAccAWSELBConfigIdleTimeout_update = ` 659 resource "aws_elb" "bar" { 660 name = "foobar-terraform-test" 661 availability_zones = ["us-west-2a"] 662 663 listener { 664 instance_port = 8000 665 instance_protocol = "http" 666 lb_port = 80 667 lb_protocol = "http" 668 } 669 670 idle_timeout = 400 671 } 672 ` 673 674 const testAccAWSELBConfigConnectionDraining = ` 675 resource "aws_elb" "bar" { 676 name = "foobar-terraform-test" 677 availability_zones = ["us-west-2a"] 678 679 listener { 680 instance_port = 8000 681 instance_protocol = "http" 682 lb_port = 80 683 lb_protocol = "http" 684 } 685 686 connection_draining = true 687 connection_draining_timeout = 400 688 } 689 ` 690 691 const testAccAWSELBConfigConnectionDraining_update_timeout = ` 692 resource "aws_elb" "bar" { 693 name = "foobar-terraform-test" 694 availability_zones = ["us-west-2a"] 695 696 listener { 697 instance_port = 8000 698 instance_protocol = "http" 699 lb_port = 80 700 lb_protocol = "http" 701 } 702 703 connection_draining = true 704 connection_draining_timeout = 400 705 } 706 ` 707 708 const testAccAWSELBConfigConnectionDraining_update_disable = ` 709 resource "aws_elb" "bar" { 710 name = "foobar-terraform-test" 711 availability_zones = ["us-west-2a"] 712 713 listener { 714 instance_port = 8000 715 instance_protocol = "http" 716 lb_port = 80 717 lb_protocol = "http" 718 } 719 720 connection_draining = false 721 } 722 ` 723 724 const testAccAWSELBConfigSecurityGroups = ` 725 resource "aws_elb" "bar" { 726 name = "foobar-terraform-test" 727 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 728 729 listener { 730 instance_port = 8000 731 instance_protocol = "http" 732 lb_port = 80 733 lb_protocol = "http" 734 } 735 736 security_groups = ["${aws_security_group.bar.id}"] 737 } 738 739 resource "aws_security_group" "bar" { 740 name = "terraform-elb-acceptance-test" 741 description = "Used in the terraform acceptance tests for the elb resource" 742 743 ingress { 744 protocol = "tcp" 745 from_port = 80 746 to_port = 80 747 cidr_blocks = ["0.0.0.0/0"] 748 } 749 } 750 `