diff --git a/aws/resource_aws_ecs_task_definition_test.go b/aws/resource_aws_ecs_task_definition_test.go index a2e38d86434..a2824e4816a 100644 --- a/aws/resource_aws_ecs_task_definition_test.go +++ b/aws/resource_aws_ecs_task_definition_test.go @@ -96,6 +96,18 @@ func TestAccAWSEcsTaskDefinition_basic(t *testing.T) { ImportStateIdFunc: testAccAWSEcsTaskDefinitionImportStateIdFunc(resourceName), ImportStateVerify: true, }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateIdFunc: testAccAWSEcsTaskDefinitionImportStateIdUsingFamilyAndRevisionFunc(resourceName), + ImportStateVerify: true, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateIdFunc: testAccAWSEcsTaskDefinitionImportStateIdUsingArnFunc(resourceName), + ImportStateVerify: true, + }, }, }) } @@ -2060,3 +2072,25 @@ func testAccAWSEcsTaskDefinitionImportStateIdFunc(resourceName string) resource. return rs.Primary.Attributes["family"], nil } } + +func testAccAWSEcsTaskDefinitionImportStateIdUsingFamilyAndRevisionFunc(resourceName string) resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return "", fmt.Errorf("Not found: %s", resourceName) + } + + return fmt.Sprintf("%s:%s", rs.Primary.Attributes["family"], rs.Primary.Attributes["revision"]), nil + } +} + +func testAccAWSEcsTaskDefinitionImportStateIdUsingArnFunc(resourceName string) resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return "", fmt.Errorf("Not found: %s", resourceName) + } + + return rs.Primary.Attributes["arn"], nil + } +}