From fc1679d2e62c835d00722f4f05ee9f2c8a31d33c Mon Sep 17 00:00:00 2001 From: Touch Ungboriboonpisal Date: Wed, 13 Jun 2018 03:26:25 -0700 Subject: [PATCH 1/5] aws_ecs_service: add support for scheduling_strategy Fixes #4820 --- aws/data_source_aws_ecs_service.go | 5 + aws/data_source_aws_ecs_service_test.go | 1 + aws/resource_aws_ecs_service.go | 12 +++ aws/resource_aws_ecs_service_test.go | 127 +++++++++++++++++++++++ website/docs/d/ecs_service.html.markdown | 1 + website/docs/r/ecs_service.html.markdown | 1 + 6 files changed, 147 insertions(+) diff --git a/aws/data_source_aws_ecs_service.go b/aws/data_source_aws_ecs_service.go index 574bd98f755..524b47f7334 100644 --- a/aws/data_source_aws_ecs_service.go +++ b/aws/data_source_aws_ecs_service.go @@ -36,6 +36,10 @@ func dataSourceAwsEcsService() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "scheduling_strategy": { + Type: schema.TypeString, + Computed: true, + }, "task_definition": { Type: schema.TypeString, Computed: true, @@ -78,6 +82,7 @@ func dataSourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error d.Set("cluster_arn", service.ClusterArn) d.Set("desired_count", service.DesiredCount) d.Set("launch_type", service.LaunchType) + d.Set("scheduling_strategy", service.SchedulingStrategy) d.Set("task_definition", service.TaskDefinition) return nil diff --git a/aws/data_source_aws_ecs_service_test.go b/aws/data_source_aws_ecs_service_test.go index 269a6bde762..24d89fd25d3 100644 --- a/aws/data_source_aws_ecs_service_test.go +++ b/aws/data_source_aws_ecs_service_test.go @@ -22,6 +22,7 @@ func TestAccAWSEcsServiceDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "id", dataSourceName, "arn"), resource.TestCheckResourceAttrPair(resourceName, "desired_count", dataSourceName, "desired_count"), resource.TestCheckResourceAttrPair(resourceName, "launch_type", dataSourceName, "launch_type"), + resource.TestCheckResourceAttrPair(resourceName, "scheduling_strategy", dataSourceName, "scheduling_strategy"), resource.TestCheckResourceAttrPair(resourceName, "name", dataSourceName, "service_name"), resource.TestCheckResourceAttrPair(resourceName, "task_definition", dataSourceName, "task_definition"), ), diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index 7d27a27c9f9..c2515eb26e5 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -66,6 +66,13 @@ func resourceAwsEcsService() *schema.Resource { Default: "EC2", }, + "scheduling_strategy": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "REPLICA", + }, + "iam_role": { Type: schema.TypeString, ForceNew: true, @@ -321,6 +328,10 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error input.LaunchType = aws.String(v.(string)) } + if v, ok := d.GetOk("scheduling_strategy"); ok { + input.SchedulingStrategy = aws.String(v.(string)) + } + loadBalancers := expandEcsLoadBalancers(d.Get("load_balancer").(*schema.Set).List()) if len(loadBalancers) > 0 { log.Printf("[DEBUG] Adding ECS load balancers: %s", loadBalancers) @@ -492,6 +503,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { d.Set("desired_count", service.DesiredCount) d.Set("health_check_grace_period_seconds", service.HealthCheckGracePeriodSeconds) d.Set("launch_type", service.LaunchType) + d.Set("scheduling_strategy", service.SchedulingStrategy) // Save cluster in the same format if strings.HasPrefix(d.Get("cluster").(string), "arn:"+meta.(*AWSClient).partition+":ecs:") { diff --git a/aws/resource_aws_ecs_service_test.go b/aws/resource_aws_ecs_service_test.go index 7532d1cea8d..85084edf9eb 100644 --- a/aws/resource_aws_ecs_service_test.go +++ b/aws/resource_aws_ecs_service_test.go @@ -626,6 +626,78 @@ func TestAccAWSEcsService_withLaunchTypeEC2AndNetworkConfiguration(t *testing.T) }) } +func TestAccAWSEcsService_withDefaultSchedulingStrategy(t *testing.T) { + var service ecs.Service + rString := acctest.RandString(8) + + clusterName := fmt.Sprintf("tf-acc-cluster-svc-w-ss-default-%s", rString) + tdName := fmt.Sprintf("tf-acc-td-svc-w-ss-default-%s", rString) + svcName := fmt.Sprintf("tf-acc-svc-w-ss-default-%s", rString) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsServiceWithDefaultSchedulingStrategy(clusterName, tdName, svcName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), + resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "REPLICA"), + ), + }, + }, + }) +} + +func TestAccAWSEcsService_withDaemonSchedulingStrategy(t *testing.T) { + var service ecs.Service + rString := acctest.RandString(8) + + clusterName := fmt.Sprintf("tf-acc-cluster-svc-w-ss-daemon-%s", rString) + tdName := fmt.Sprintf("tf-acc-td-svc-w-ss-daemon-%s", rString) + svcName := fmt.Sprintf("tf-acc-svc-w-ss-daemon-%s", rString) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, "DAEMON"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), + resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "DAEMON"), + ), + }, + }, + }) +} + +func TestAccAWSEcsService_withReplicaSchedulingStrategy(t *testing.T) { + var service ecs.Service + rString := acctest.RandString(8) + + clusterName := fmt.Sprintf("tf-acc-cluster-svc-w-ss-replica-%s", rString) + tdName := fmt.Sprintf("tf-acc-td-svc-w-ss-replica-%s", rString) + svcName := fmt.Sprintf("tf-acc-svc-w-ss-replica-%s", rString) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, "REPLICA"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), + resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "REPLICA"), + ), + }, + }, + }) +} + func TestAccAWSEcsService_withServiceRegistries(t *testing.T) { var service ecs.Service rString := acctest.RandString(8) @@ -1955,3 +2027,58 @@ resource "aws_ecs_service" "test" { } `, rName, rName, rName, clusterName, tdName, svcName) } + +func testAccAWSEcsServiceWithDefaultSchedulingStrategy(clusterName, tdName, svcName string) string { + return fmt.Sprintf(` +resource "aws_ecs_cluster" "default" { + name = "%s" +} +resource "aws_ecs_task_definition" "ghost" { + family = "%s" + container_definitions = < Date: Wed, 13 Jun 2018 04:02:13 -0700 Subject: [PATCH 2/5] auto ignore desired count for DAEMON scheduling strategy --- aws/resource_aws_ecs_service.go | 14 +++++++++++--- aws/resource_aws_ecs_service_test.go | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index c2515eb26e5..dce31898fa0 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -329,7 +329,12 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error } if v, ok := d.GetOk("scheduling_strategy"); ok { - input.SchedulingStrategy = aws.String(v.(string)) + schedulingStrategy := v.(string) + input.SchedulingStrategy = aws.String(schedulingStrategy) + if schedulingStrategy == "DAEMON" { + // unset desired count if DAEMON + input.DesiredCount = nil + } } loadBalancers := expandEcsLoadBalancers(d.Get("load_balancer").(*schema.Set).List()) @@ -500,10 +505,13 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { d.Set("task_definition", taskDefinition) } - d.Set("desired_count", service.DesiredCount) + d.Set("scheduling_strategy", service.SchedulingStrategy) + // Automatically ignore desired count if DAEMON + if *service.SchedulingStrategy != "DAEMON" { + d.Set("desired_count", service.DesiredCount) + } d.Set("health_check_grace_period_seconds", service.HealthCheckGracePeriodSeconds) d.Set("launch_type", service.LaunchType) - d.Set("scheduling_strategy", service.SchedulingStrategy) // Save cluster in the same format if strings.HasPrefix(d.Get("cluster").(string), "arn:"+meta.(*AWSClient).partition+":ecs:") { diff --git a/aws/resource_aws_ecs_service_test.go b/aws/resource_aws_ecs_service_test.go index 85084edf9eb..fab852a345b 100644 --- a/aws/resource_aws_ecs_service_test.go +++ b/aws/resource_aws_ecs_service_test.go @@ -2051,6 +2051,7 @@ resource "aws_ecs_service" "ghost" { name = "%s" cluster = "${aws_ecs_cluster.default.id}" task_definition = "${aws_ecs_task_definition.ghost.family}:${aws_ecs_task_definition.ghost.revision}" + desired_count = 10 // this should be ignored } `, clusterName, tdName, svcName) } From 6b5fa9e3d94240e4ffd58cfa25f9b8f177102964 Mon Sep 17 00:00:00 2001 From: Touch Ungboriboonpisal Date: Wed, 13 Jun 2018 04:03:57 -0700 Subject: [PATCH 3/5] update tests --- aws/resource_aws_ecs_service_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_ecs_service_test.go b/aws/resource_aws_ecs_service_test.go index fab852a345b..4c25a489d4f 100644 --- a/aws/resource_aws_ecs_service_test.go +++ b/aws/resource_aws_ecs_service_test.go @@ -2051,7 +2051,7 @@ resource "aws_ecs_service" "ghost" { name = "%s" cluster = "${aws_ecs_cluster.default.id}" task_definition = "${aws_ecs_task_definition.ghost.family}:${aws_ecs_task_definition.ghost.revision}" - desired_count = 10 // this should be ignored + desired_count = 1 } `, clusterName, tdName, svcName) } @@ -2079,6 +2079,7 @@ resource "aws_ecs_service" "ghost" { name = "%s" cluster = "${aws_ecs_cluster.default.id}" task_definition = "${aws_ecs_task_definition.ghost.family}:${aws_ecs_task_definition.ghost.revision}" + desired_count = 1 scheduling_strategy = "%s" } `, clusterName, tdName, svcName, schedulingStrategy) From 81e7818efd2591bfa4c6f2f422ac1cba2553f5ad Mon Sep 17 00:00:00 2001 From: Touch Ungboriboonpisal Date: Wed, 13 Jun 2018 16:48:44 -0700 Subject: [PATCH 4/5] do not require desired_count in DAEMON scheduling strategy --- aws/resource_aws_ecs_service.go | 10 +++-- aws/resource_aws_ecs_service_test.go | 49 ++++++++---------------- website/docs/r/ecs_service.html.markdown | 2 +- 3 files changed, 23 insertions(+), 38 deletions(-) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index dce31898fa0..8ba2dc0b823 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -17,6 +17,8 @@ import ( "github.com/hashicorp/terraform/helper/validation" ) +const schedulingStrategyDaemon = "DAEMON" + var taskDefinitionRE = regexp.MustCompile("^([a-zA-Z0-9_-]+):([0-9]+)$") func resourceAwsEcsService() *schema.Resource { @@ -331,7 +333,7 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error if v, ok := d.GetOk("scheduling_strategy"); ok { schedulingStrategy := v.(string) input.SchedulingStrategy = aws.String(schedulingStrategy) - if schedulingStrategy == "DAEMON" { + if schedulingStrategy == schedulingStrategyDaemon { // unset desired count if DAEMON input.DesiredCount = nil } @@ -507,7 +509,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { d.Set("scheduling_strategy", service.SchedulingStrategy) // Automatically ignore desired count if DAEMON - if *service.SchedulingStrategy != "DAEMON" { + if *service.SchedulingStrategy != schedulingStrategyDaemon { d.Set("desired_count", service.DesiredCount) } d.Set("health_check_grace_period_seconds", service.HealthCheckGracePeriodSeconds) @@ -729,7 +731,9 @@ func resourceAwsEcsServiceUpdate(d *schema.ResourceData, meta interface{}) error Cluster: aws.String(d.Get("cluster").(string)), } - if d.HasChange("desired_count") { + schedulingStrategy := d.Get("scheduling_strategy").(string) + // Automatically ignore desired count if DAEMON + if schedulingStrategy != schedulingStrategyDaemon && d.HasChange("desired_count") { _, n := d.GetChange("desired_count") input.DesiredCount = aws.Int64(int64(n.(int))) } diff --git a/aws/resource_aws_ecs_service_test.go b/aws/resource_aws_ecs_service_test.go index 4c25a489d4f..7691807117a 100644 --- a/aws/resource_aws_ecs_service_test.go +++ b/aws/resource_aws_ecs_service_test.go @@ -640,7 +640,7 @@ func TestAccAWSEcsService_withDefaultSchedulingStrategy(t *testing.T) { CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithDefaultSchedulingStrategy(clusterName, tdName, svcName), + Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, nil, aws.Int(1)), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "REPLICA"), @@ -664,7 +664,7 @@ func TestAccAWSEcsService_withDaemonSchedulingStrategy(t *testing.T) { CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, "DAEMON"), + Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, aws.String("DAEMON"), nil), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "DAEMON"), @@ -688,7 +688,7 @@ func TestAccAWSEcsService_withReplicaSchedulingStrategy(t *testing.T) { CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, "REPLICA"), + Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, aws.String("REPLICA"), aws.Int(1)), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "REPLICA"), @@ -2028,35 +2028,16 @@ resource "aws_ecs_service" "test" { `, rName, rName, rName, clusterName, tdName, svcName) } -func testAccAWSEcsServiceWithDefaultSchedulingStrategy(clusterName, tdName, svcName string) string { - return fmt.Sprintf(` -resource "aws_ecs_cluster" "default" { - name = "%s" -} -resource "aws_ecs_task_definition" "ghost" { - family = "%s" - container_definitions = < Date: Thu, 14 Jun 2018 08:31:00 -0700 Subject: [PATCH 5/5] code review feedback --- aws/resource_aws_ecs_service.go | 24 ++++---- aws/resource_aws_ecs_service_test.go | 74 ++++++++++++------------ website/docs/r/ecs_service.html.markdown | 16 ++++- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index 8ba2dc0b823..5df81ad34ff 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -17,8 +17,6 @@ import ( "github.com/hashicorp/terraform/helper/validation" ) -const schedulingStrategyDaemon = "DAEMON" - var taskDefinitionRE = regexp.MustCompile("^([a-zA-Z0-9_-]+):([0-9]+)$") func resourceAwsEcsService() *schema.Resource { @@ -72,7 +70,11 @@ func resourceAwsEcsService() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - Default: "REPLICA", + Default: ecs.SchedulingStrategyReplica, + ValidateFunc: validation.StringInSlice([]string{ + ecs.SchedulingStrategyDaemon, + ecs.SchedulingStrategyReplica, + }, false), }, "iam_role": { @@ -330,13 +332,11 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error input.LaunchType = aws.String(v.(string)) } - if v, ok := d.GetOk("scheduling_strategy"); ok { - schedulingStrategy := v.(string) - input.SchedulingStrategy = aws.String(schedulingStrategy) - if schedulingStrategy == schedulingStrategyDaemon { - // unset desired count if DAEMON - input.DesiredCount = nil - } + schedulingStrategy := d.Get("scheduling_strategy").(string) + input.SchedulingStrategy = aws.String(schedulingStrategy) + if schedulingStrategy == ecs.SchedulingStrategyDaemon { + // unset desired count if DAEMON + input.DesiredCount = nil } loadBalancers := expandEcsLoadBalancers(d.Get("load_balancer").(*schema.Set).List()) @@ -509,7 +509,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { d.Set("scheduling_strategy", service.SchedulingStrategy) // Automatically ignore desired count if DAEMON - if *service.SchedulingStrategy != schedulingStrategyDaemon { + if *service.SchedulingStrategy != ecs.SchedulingStrategyDaemon { d.Set("desired_count", service.DesiredCount) } d.Set("health_check_grace_period_seconds", service.HealthCheckGracePeriodSeconds) @@ -733,7 +733,7 @@ func resourceAwsEcsServiceUpdate(d *schema.ResourceData, meta interface{}) error schedulingStrategy := d.Get("scheduling_strategy").(string) // Automatically ignore desired count if DAEMON - if schedulingStrategy != schedulingStrategyDaemon && d.HasChange("desired_count") { + if schedulingStrategy != ecs.SchedulingStrategyDaemon && d.HasChange("desired_count") { _, n := d.GetChange("desired_count") input.DesiredCount = aws.Int64(int64(n.(int))) } diff --git a/aws/resource_aws_ecs_service_test.go b/aws/resource_aws_ecs_service_test.go index 7691807117a..e95b2f7307d 100644 --- a/aws/resource_aws_ecs_service_test.go +++ b/aws/resource_aws_ecs_service_test.go @@ -103,6 +103,7 @@ func TestAccAWSEcsService_withARN(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo", &service), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "service_registries.#", "0"), + resource.TestCheckResourceAttr("aws_ecs_service.mongo", "scheduling_strategy", "REPLICA"), ), }, @@ -111,6 +112,7 @@ func TestAccAWSEcsService_withARN(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo", &service), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "service_registries.#", "0"), + resource.TestCheckResourceAttr("aws_ecs_service.mongo", "scheduling_strategy", "REPLICA"), ), }, }, @@ -626,30 +628,6 @@ func TestAccAWSEcsService_withLaunchTypeEC2AndNetworkConfiguration(t *testing.T) }) } -func TestAccAWSEcsService_withDefaultSchedulingStrategy(t *testing.T) { - var service ecs.Service - rString := acctest.RandString(8) - - clusterName := fmt.Sprintf("tf-acc-cluster-svc-w-ss-default-%s", rString) - tdName := fmt.Sprintf("tf-acc-td-svc-w-ss-default-%s", rString) - svcName := fmt.Sprintf("tf-acc-svc-w-ss-default-%s", rString) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSEcsServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, nil, aws.Int(1)), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), - resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "REPLICA"), - ), - }, - }, - }) -} - func TestAccAWSEcsService_withDaemonSchedulingStrategy(t *testing.T) { var service ecs.Service rString := acctest.RandString(8) @@ -664,7 +642,7 @@ func TestAccAWSEcsService_withDaemonSchedulingStrategy(t *testing.T) { CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, aws.String("DAEMON"), nil), + Config: testAccAWSEcsServiceWithDaemonSchedulingStrategy(clusterName, tdName, svcName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "DAEMON"), @@ -688,7 +666,7 @@ func TestAccAWSEcsService_withReplicaSchedulingStrategy(t *testing.T) { CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName, aws.String("REPLICA"), aws.Int(1)), + Config: testAccAWSEcsServiceWithReplicaSchedulingStrategy(clusterName, tdName, svcName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.ghost", &service), resource.TestCheckResourceAttr("aws_ecs_service.ghost", "scheduling_strategy", "REPLICA"), @@ -2028,16 +2006,36 @@ resource "aws_ecs_service" "test" { `, rName, rName, rName, clusterName, tdName, svcName) } -func testAccAWSEcsServiceWithSchedulingStrategy(clusterName, tdName, svcName string, schedulingStrategy *string, desiredCount *int) string { - schedulingStrategySnippet := "" - if schedulingStrategy != nil { - schedulingStrategySnippet += fmt.Sprintf(`scheduling_strategy = "%s"`, *schedulingStrategy) - } - desiredCountSnippet := "" - if desiredCount != nil { - desiredCountSnippet += fmt.Sprintf(`desired_count = %d`, *desiredCount) - } +func testAccAWSEcsServiceWithDaemonSchedulingStrategy(clusterName, tdName, svcName string) string { + return fmt.Sprintf(` +resource "aws_ecs_cluster" "default" { + name = "%s" +} +resource "aws_ecs_task_definition" "ghost" { + family = "%s" + container_definitions = <