providers/aws: tests and document adding load balancers to autoscaling
cc/ @thatha
This commit is contained in:
parent
89041c0595
commit
97cae408b2
|
@ -30,6 +30,8 @@ BUG FIXES:
|
|||
* core: Key files for provisioning can now contain `~` and will be expanded
|
||||
to the user's home directory. [GH-179]
|
||||
* providers/aws: Fix issues around failing to read EIPs. [GH-122]
|
||||
* providers/aws: Autoscaling groups now register and export load
|
||||
balancers. [GH-207]
|
||||
* providers/heroku: If you delete the `config_vars` block, config vars
|
||||
are properly nuked.
|
||||
* providers/heroku: Domains and drains are deleted before the app.
|
||||
|
|
|
@ -44,6 +44,24 @@ func TestAccAWSAutoScalingGroup(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSAutoScalingGroupWithLoadBalancer(t *testing.T) {
|
||||
var group autoscaling.AutoScalingGroup
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSAutoScalingGroupConfigWithLoadBalancer,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group),
|
||||
testAccCheckAWSAutoScalingGroupAttributesLoadBalancer(&group),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
func testAccCheckAWSAutoScalingGroupDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.autoscalingconn
|
||||
|
||||
|
@ -116,6 +134,16 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGro
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckAWSAutoScalingGroupAttributesLoadBalancer(group *autoscaling.AutoScalingGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
if group.LoadBalancerNames[0].LoadBalancerName != "foobar-terraform-test" {
|
||||
return fmt.Errorf("Bad load_balancers: %s", group.LoadBalancerNames[0].LoadBalancerName)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testAccCheckAWSAutoScalingGroupExists(n string, group *autoscaling.AutoScalingGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.Resources[n]
|
||||
|
@ -169,3 +197,37 @@ resource "aws_autoscaling_group" "bar" {
|
|||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccAWSAutoScalingGroupConfigWithLoadBalancer = `
|
||||
resource "aws_elb" "bar" {
|
||||
name = "foobar-terraform-test"
|
||||
availability_zones = ["us-west-2a"]
|
||||
|
||||
listener {
|
||||
instance_port = 8000
|
||||
instance_protocol = "http"
|
||||
lb_port = 80
|
||||
lb_protocol = "http"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "foobar" {
|
||||
name = "foobarautoscaling-terraform-test"
|
||||
image_id = "ami-21f78e11"
|
||||
instance_type = "t1.micro"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "bar" {
|
||||
availability_zones = ["us-west-2a"]
|
||||
name = "foobar3-terraform-test"
|
||||
max_size = 5
|
||||
min_size = 2
|
||||
health_check_grace_period = 300
|
||||
health_check_type = "ELB"
|
||||
desired_capacity = 4
|
||||
force_delete = true
|
||||
|
||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||
load_balancers = ["${aws_elb.bar.name}"]
|
||||
}
|
||||
`
|
||||
|
|
|
@ -38,6 +38,8 @@ The following arguments are supported:
|
|||
* `desired_capacity` - (Optional) The number of Amazon EC2 instances that should be running in the group.
|
||||
* `force_delete` - (Optional) Allows deleting the autoscaling group without waiting
|
||||
for all instances in the pool to terminate.
|
||||
* `load_balancers` (Optional) A list of load balancer names to add to the autoscaling
|
||||
group names.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
|
@ -54,4 +56,5 @@ The following attributes are exported:
|
|||
* `desired_capacity` -The number of Amazon EC2 instances that should be running in the group.
|
||||
* `launch_configuration` - The launch configuration of the autoscale group
|
||||
* `vpc_zone_identifier` - The VPC zone identifier
|
||||
|
||||
* `load_balancers` (Optional) The load balancer names associated with the
|
||||
autoscaling group.
|
||||
|
|
Loading…
Reference in New Issue