github.com/bendemaree/terraform@v0.5.4-0.20150613200311-f50d97d6eee6/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/aws/aws-sdk-go/aws" 11 "github.com/aws/aws-sdk-go/aws/awserr" 12 "github.com/aws/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 // Unit test for listeners hash 366 func TestResourceAwsElbListenerHash(t *testing.T) { 367 cases := map[string]struct { 368 Left map[string]interface{} 369 Right map[string]interface{} 370 Match bool 371 }{ 372 "protocols are case insensitive": { 373 map[string]interface{}{ 374 "instance_port": 80, 375 "instance_protocol": "TCP", 376 "lb_port": 80, 377 "lb_protocol": "TCP", 378 }, 379 map[string]interface{}{ 380 "instance_port": 80, 381 "instance_protocol": "Tcp", 382 "lb_port": 80, 383 "lb_protocol": "tcP", 384 }, 385 true, 386 }, 387 } 388 389 for tn, tc := range cases { 390 leftHash := resourceAwsElbListenerHash(tc.Left) 391 rightHash := resourceAwsElbListenerHash(tc.Right) 392 if (leftHash == rightHash) != tc.Match { 393 t.Fatalf("%s: expected match: %t, but did not get it", tn, tc.Match) 394 } 395 } 396 } 397 398 func testAccCheckAWSELBDestroy(s *terraform.State) error { 399 conn := testAccProvider.Meta().(*AWSClient).elbconn 400 401 for _, rs := range s.RootModule().Resources { 402 if rs.Type != "aws_elb" { 403 continue 404 } 405 406 describe, err := conn.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{ 407 LoadBalancerNames: []*string{aws.String(rs.Primary.ID)}, 408 }) 409 410 if err == nil { 411 if len(describe.LoadBalancerDescriptions) != 0 && 412 *describe.LoadBalancerDescriptions[0].LoadBalancerName == rs.Primary.ID { 413 return fmt.Errorf("ELB still exists") 414 } 415 } 416 417 // Verify the error 418 providerErr, ok := err.(awserr.Error) 419 if !ok { 420 return err 421 } 422 423 if providerErr.Code() != "InvalidLoadBalancerName.NotFound" { 424 return fmt.Errorf("Unexpected error: %s", err) 425 } 426 } 427 428 return nil 429 } 430 431 func testAccCheckAWSELBAttributes(conf *elb.LoadBalancerDescription) resource.TestCheckFunc { 432 return func(s *terraform.State) error { 433 zones := []string{"us-west-2a", "us-west-2b", "us-west-2c"} 434 azs := make([]string, 0, len(conf.AvailabilityZones)) 435 for _, x := range conf.AvailabilityZones { 436 azs = append(azs, *x) 437 } 438 sort.StringSlice(azs).Sort() 439 if !reflect.DeepEqual(azs, zones) { 440 return fmt.Errorf("bad availability_zones") 441 } 442 443 if *conf.LoadBalancerName != "foobar-terraform-test" { 444 return fmt.Errorf("bad name") 445 } 446 447 l := elb.Listener{ 448 InstancePort: aws.Long(int64(8000)), 449 InstanceProtocol: aws.String("HTTP"), 450 LoadBalancerPort: aws.Long(int64(80)), 451 Protocol: aws.String("HTTP"), 452 } 453 454 if !reflect.DeepEqual(conf.ListenerDescriptions[0].Listener, &l) { 455 return fmt.Errorf( 456 "Got:\n\n%#v\n\nExpected:\n\n%#v\n", 457 conf.ListenerDescriptions[0].Listener, 458 l) 459 } 460 461 if *conf.DNSName == "" { 462 return fmt.Errorf("empty dns_name") 463 } 464 465 return nil 466 } 467 } 468 469 func testAccCheckAWSELBAttributesHealthCheck(conf *elb.LoadBalancerDescription) resource.TestCheckFunc { 470 return func(s *terraform.State) error { 471 zones := []string{"us-west-2a", "us-west-2b", "us-west-2c"} 472 azs := make([]string, 0, len(conf.AvailabilityZones)) 473 for _, x := range conf.AvailabilityZones { 474 azs = append(azs, *x) 475 } 476 sort.StringSlice(azs).Sort() 477 if !reflect.DeepEqual(azs, zones) { 478 return fmt.Errorf("bad availability_zones") 479 } 480 481 if *conf.LoadBalancerName != "foobar-terraform-test" { 482 return fmt.Errorf("bad name") 483 } 484 485 check := &elb.HealthCheck{ 486 Timeout: aws.Long(int64(30)), 487 UnhealthyThreshold: aws.Long(int64(5)), 488 HealthyThreshold: aws.Long(int64(5)), 489 Interval: aws.Long(int64(60)), 490 Target: aws.String("HTTP:8000/"), 491 } 492 493 if !reflect.DeepEqual(conf.HealthCheck, check) { 494 return fmt.Errorf( 495 "Got:\n\n%#v\n\nExpected:\n\n%#v\n", 496 conf.HealthCheck, 497 check) 498 } 499 500 if *conf.DNSName == "" { 501 return fmt.Errorf("empty dns_name") 502 } 503 504 return nil 505 } 506 } 507 508 func testAccCheckAWSELBExists(n string, res *elb.LoadBalancerDescription) resource.TestCheckFunc { 509 return func(s *terraform.State) error { 510 rs, ok := s.RootModule().Resources[n] 511 if !ok { 512 return fmt.Errorf("Not found: %s", n) 513 } 514 515 if rs.Primary.ID == "" { 516 return fmt.Errorf("No ELB ID is set") 517 } 518 519 conn := testAccProvider.Meta().(*AWSClient).elbconn 520 521 describe, err := conn.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{ 522 LoadBalancerNames: []*string{aws.String(rs.Primary.ID)}, 523 }) 524 525 if err != nil { 526 return err 527 } 528 529 if len(describe.LoadBalancerDescriptions) != 1 || 530 *describe.LoadBalancerDescriptions[0].LoadBalancerName != rs.Primary.ID { 531 return fmt.Errorf("ELB not found") 532 } 533 534 *res = *describe.LoadBalancerDescriptions[0] 535 536 return nil 537 } 538 } 539 540 const testAccAWSELBConfig = ` 541 resource "aws_elb" "bar" { 542 name = "foobar-terraform-test" 543 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 544 545 listener { 546 instance_port = 8000 547 instance_protocol = "http" 548 lb_port = 80 549 // Protocol should be case insensitive 550 lb_protocol = "HttP" 551 } 552 553 tags { 554 bar = "baz" 555 } 556 557 cross_zone_load_balancing = true 558 } 559 ` 560 561 const testAccAWSELBConfig_TagUpdate = ` 562 resource "aws_elb" "bar" { 563 name = "foobar-terraform-test" 564 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 565 566 listener { 567 instance_port = 8000 568 instance_protocol = "http" 569 lb_port = 80 570 lb_protocol = "http" 571 } 572 573 tags { 574 foo = "bar" 575 new = "type" 576 } 577 578 cross_zone_load_balancing = true 579 } 580 ` 581 582 const testAccAWSELBConfigNewInstance = ` 583 resource "aws_elb" "bar" { 584 name = "foobar-terraform-test" 585 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 586 587 listener { 588 instance_port = 8000 589 instance_protocol = "http" 590 lb_port = 80 591 lb_protocol = "http" 592 } 593 594 instances = ["${aws_instance.foo.id}"] 595 } 596 597 resource "aws_instance" "foo" { 598 # us-west-2 599 ami = "ami-043a5034" 600 instance_type = "t1.micro" 601 } 602 ` 603 604 const testAccAWSELBConfigListenerSSLCertificateId = ` 605 resource "aws_elb" "bar" { 606 name = "foobar-terraform-test" 607 availability_zones = ["us-west-2a"] 608 609 listener { 610 instance_port = 8000 611 instance_protocol = "http" 612 ssl_certificate_id = "%s" 613 lb_port = 443 614 lb_protocol = "https" 615 } 616 } 617 ` 618 619 const testAccAWSELBConfigHealthCheck = ` 620 resource "aws_elb" "bar" { 621 name = "foobar-terraform-test" 622 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 623 624 listener { 625 instance_port = 8000 626 instance_protocol = "http" 627 lb_port = 80 628 lb_protocol = "http" 629 } 630 631 health_check { 632 healthy_threshold = 5 633 unhealthy_threshold = 5 634 target = "HTTP:8000/" 635 interval = 60 636 timeout = 30 637 } 638 } 639 ` 640 641 const testAccAWSELBConfigHealthCheck_update = ` 642 resource "aws_elb" "bar" { 643 name = "foobar-terraform-test" 644 availability_zones = ["us-west-2a"] 645 646 listener { 647 instance_port = 8000 648 instance_protocol = "http" 649 lb_port = 80 650 lb_protocol = "http" 651 } 652 653 health_check { 654 healthy_threshold = 10 655 unhealthy_threshold = 5 656 target = "HTTP:8000/" 657 interval = 60 658 timeout = 30 659 } 660 } 661 ` 662 663 const testAccAWSELBConfigListener_update = ` 664 resource "aws_elb" "bar" { 665 name = "foobar-terraform-test" 666 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 667 668 listener { 669 instance_port = 8080 670 instance_protocol = "http" 671 lb_port = 80 672 lb_protocol = "http" 673 } 674 } 675 ` 676 677 const testAccAWSELBConfigIdleTimeout = ` 678 resource "aws_elb" "bar" { 679 name = "foobar-terraform-test" 680 availability_zones = ["us-west-2a"] 681 682 listener { 683 instance_port = 8000 684 instance_protocol = "http" 685 lb_port = 80 686 lb_protocol = "http" 687 } 688 689 idle_timeout = 200 690 } 691 ` 692 693 const testAccAWSELBConfigIdleTimeout_update = ` 694 resource "aws_elb" "bar" { 695 name = "foobar-terraform-test" 696 availability_zones = ["us-west-2a"] 697 698 listener { 699 instance_port = 8000 700 instance_protocol = "http" 701 lb_port = 80 702 lb_protocol = "http" 703 } 704 705 idle_timeout = 400 706 } 707 ` 708 709 const testAccAWSELBConfigConnectionDraining = ` 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 = true 722 connection_draining_timeout = 400 723 } 724 ` 725 726 const testAccAWSELBConfigConnectionDraining_update_timeout = ` 727 resource "aws_elb" "bar" { 728 name = "foobar-terraform-test" 729 availability_zones = ["us-west-2a"] 730 731 listener { 732 instance_port = 8000 733 instance_protocol = "http" 734 lb_port = 80 735 lb_protocol = "http" 736 } 737 738 connection_draining = true 739 connection_draining_timeout = 600 740 } 741 ` 742 743 const testAccAWSELBConfigConnectionDraining_update_disable = ` 744 resource "aws_elb" "bar" { 745 name = "foobar-terraform-test" 746 availability_zones = ["us-west-2a"] 747 748 listener { 749 instance_port = 8000 750 instance_protocol = "http" 751 lb_port = 80 752 lb_protocol = "http" 753 } 754 755 connection_draining = false 756 } 757 ` 758 759 const testAccAWSELBConfigSecurityGroups = ` 760 resource "aws_elb" "bar" { 761 name = "foobar-terraform-test" 762 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 763 764 listener { 765 instance_port = 8000 766 instance_protocol = "http" 767 lb_port = 80 768 lb_protocol = "http" 769 } 770 771 security_groups = ["${aws_security_group.bar.id}"] 772 } 773 774 resource "aws_security_group" "bar" { 775 name = "terraform-elb-acceptance-test" 776 description = "Used in the terraform acceptance tests for the elb resource" 777 778 ingress { 779 protocol = "tcp" 780 from_port = 80 781 to_port = 80 782 cidr_blocks = ["0.0.0.0/0"] 783 } 784 } 785 `