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