diff --git a/aws/resource_aws_cloudformation_stack.go b/aws/resource_aws_cloudformation_stack.go index 7f3a61db13d..f5490b2a5d3 100644 --- a/aws/resource_aws_cloudformation_stack.go +++ b/aws/resource_aws_cloudformation_stack.go @@ -21,6 +21,10 @@ func resourceAwsCloudFormationStack() *schema.Resource { Update: resourceAwsCloudFormationStackUpdate, Delete: resourceAwsCloudFormationStackDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Update: schema.DefaultTimeout(30 * time.Minute), diff --git a/aws/resource_aws_cloudformation_stack_test.go b/aws/resource_aws_cloudformation_stack_test.go index 67b0344bea2..174dd6293b8 100644 --- a/aws/resource_aws_cloudformation_stack_test.go +++ b/aws/resource_aws_cloudformation_stack_test.go @@ -11,6 +11,28 @@ import ( "github.com/hashicorp/terraform/terraform" ) +func TestAccAWSCloudFormation_importBasic(t *testing.T) { + stackName := fmt.Sprintf("tf-acc-test-basic-%s", acctest.RandString(10)) + + resourceName := "aws_cloudformation_stack.network" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCloudFormationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCloudFormationConfig(stackName), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAWSCloudFormation_basic(t *testing.T) { var stack cloudformation.Stack stackName := fmt.Sprintf("tf-acc-test-basic-%s", acctest.RandString(10)) diff --git a/website/docs/r/cloudformation_stack.html.markdown b/website/docs/r/cloudformation_stack.html.markdown index 38c34ad646e..4422e62f2e1 100644 --- a/website/docs/r/cloudformation_stack.html.markdown +++ b/website/docs/r/cloudformation_stack.html.markdown @@ -76,6 +76,15 @@ The following attributes are exported: * `outputs` - A map of outputs from the stack. +## Import + +Cloudformation Stacks can be imported using the `name`, e.g. + +``` +$ terraform import aws_cloudformation_stack.stack networking-stack +``` + + ## Timeouts