diff --git a/builtin/providers/aws/resource_aws_ecs_task_definition.go b/builtin/providers/aws/resource_aws_ecs_task_definition.go index 5a81ec2b8..2734afba9 100644 --- a/builtin/providers/aws/resource_aws_ecs_task_definition.go +++ b/builtin/providers/aws/resource_aws_ecs_task_definition.go @@ -70,11 +70,13 @@ func resourceAwsEcsTaskDefinition() *schema.Resource { "name": { Type: schema.TypeString, Required: true, + ForceNew: true, }, "host_path": { Type: schema.TypeString, Optional: true, + ForceNew: true, }, }, }, diff --git a/builtin/providers/aws/resource_aws_ecs_task_definition_test.go b/builtin/providers/aws/resource_aws_ecs_task_definition_test.go index c80f0fe6b..a414130cd 100644 --- a/builtin/providers/aws/resource_aws_ecs_task_definition_test.go +++ b/builtin/providers/aws/resource_aws_ecs_task_definition_test.go @@ -135,6 +135,41 @@ func TestAccAWSEcsTaskDefinition_constraint(t *testing.T) { }) } +func TestAccAWSEcsTaskDefinition_changeVolumesForcesNewResource(t *testing.T) { + var before ecs.TaskDefinition + var after ecs.TaskDefinition + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsTaskDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsTaskDefinition, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.jenkins", &before), + ), + }, + { + Config: testAccAWSEcsTaskDefinitionUpdatedVolume, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.jenkins", &after), + testAccCheckEcsTaskDefinitionRecreated(t, &before, &after), + ), + }, + }, + }) +} + +func testAccCheckEcsTaskDefinitionRecreated(t *testing.T, + before, after *ecs.TaskDefinition) resource.TestCheckFunc { + return func(s *terraform.State) error { + if *before.Revision == *after.Revision { + t.Fatalf("Expected change of TaskDefinition Revisions, but both were %v", before.Revision) + } + return nil + } +} + func testAccCheckAWSTaskDefinitionConstraintsAttrs(def *ecs.TaskDefinition) resource.TestCheckFunc { return func(s *terraform.State) error { if len(def.PlacementConstraints) != 1 { @@ -319,6 +354,55 @@ TASK_DEFINITION } ` +var testAccAWSEcsTaskDefinitionUpdatedVolume = ` +resource "aws_ecs_task_definition" "jenkins" { + family = "terraform-acc-test" + container_definitions = <