diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index 01ee9659ddc..99cef30153b 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -56,6 +56,12 @@ func resourceAwsEcsService() *schema.Resource { }, }, + "enable_ecs_managed_tags": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "health_check_grace_period_seconds": { Type: schema.TypeInt, Optional: true, @@ -329,11 +335,12 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error schedulingStrategy := d.Get("scheduling_strategy").(string) input := ecs.CreateServiceInput{ - ClientToken: aws.String(resource.UniqueId()), - SchedulingStrategy: aws.String(schedulingStrategy), - ServiceName: aws.String(d.Get("name").(string)), - Tags: tagsFromMapECS(d.Get("tags").(map[string]interface{})), - TaskDefinition: aws.String(d.Get("task_definition").(string)), + ClientToken: aws.String(resource.UniqueId()), + SchedulingStrategy: aws.String(schedulingStrategy), + ServiceName: aws.String(d.Get("name").(string)), + Tags: tagsFromMapECS(d.Get("tags").(map[string]interface{})), + TaskDefinition: aws.String(d.Get("task_definition").(string)), + EnableECSManagedTags: aws.Bool(d.Get("enable_ecs_managed_tags").(bool)), } if schedulingStrategy == ecs.SchedulingStrategyDaemon && deploymentMinimumHealthyPercent != 100 { @@ -538,6 +545,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("enable_ecs_managed_tags", service.EnableECSManagedTags) // 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 6c448838819..1c92ef43c9e 100644 --- a/aws/resource_aws_ecs_service_test.go +++ b/aws/resource_aws_ecs_service_test.go @@ -778,6 +778,28 @@ func TestAccAWSEcsService_Tags(t *testing.T) { }) } +func TestAccAWSEcsService_ManagedTags(t *testing.T) { + var service ecs.Service + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_ecs_service.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsServiceConfigManagedTags(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsServiceExists(resourceName, &service), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "enable_ecs_managed_tags", "true"), + ), + }, + }, + }) +} + func testAccCheckAWSEcsServiceDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).ecsconn @@ -2293,6 +2315,42 @@ resource "aws_ecs_service" "test" { `, rName, rName, rName, tag1Key, tag1Value, tag2Key, tag2Value) } +func testAccAWSEcsServiceConfigManagedTags(rName string) string { + return fmt.Sprintf(` +resource "aws_ecs_cluster" "test" { + name = %q +} + +resource "aws_ecs_task_definition" "test" { + family = %q + + container_definitions = <