diff --git a/builtin/providers/aws/resource_aws_ecs_service.go b/builtin/providers/aws/resource_aws_ecs_service.go index 656167485..9422a7387 100644 --- a/builtin/providers/aws/resource_aws_ecs_service.go +++ b/builtin/providers/aws/resource_aws_ecs_service.go @@ -76,7 +76,13 @@ func resourceAwsEcsService() *schema.Resource { Schema: map[string]*schema.Schema{ "elb_name": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + ForceNew: true, + }, + + "target_group_arn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, ForceNew: true, }, diff --git a/builtin/providers/aws/resource_aws_ecs_service_test.go b/builtin/providers/aws/resource_aws_ecs_service_test.go index 1d1733996..62e50e980 100644 --- a/builtin/providers/aws/resource_aws_ecs_service_test.go +++ b/builtin/providers/aws/resource_aws_ecs_service_test.go @@ -241,6 +241,22 @@ func TestAccAWSEcsService_withEcsClusterName(t *testing.T) { }) } +func TestAccAWSEcsService_withAlb(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsServiceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSEcsServiceWithAlb, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsServiceExists("aws_ecs_service.with_alb"), + ), + }, + }, + }) +} + func testAccCheckAWSEcsServiceDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).ecsconn @@ -702,3 +718,128 @@ resource "aws_ecs_service" "jenkins" { desired_count = 1 } ` + +var testAccAWSEcsServiceWithAlb = ` +data "aws_availability_zones" "available" {} + +resource "aws_vpc" "main" { + cidr_block = "10.10.0.0/16" +} + +resource "aws_subnet" "main" { + count = 2 + cidr_block = "${cidrsubnet(aws_vpc.main.cidr_block, 8, count.index)}" + availability_zone = "${data.aws_availability_zones.available.names[count.index]}" + vpc_id = "${aws_vpc.main.id}" +} + +resource "aws_ecs_cluster" "main" { + name = "terraform_acc_test_ecs_15" +} + +resource "aws_ecs_task_definition" "with_lb_changes" { + family = "tf_acc_test_ghost_lbd" + container_definitions = <