Skip to content

Commit

Permalink
Merge pull request #1432 from stack72/f-aws-cf-stack-import-1331
Browse files Browse the repository at this point in the history
resource/aws_cloudformation_stack: Add support for Import
  • Loading branch information
Ninir authored Aug 17, 2017
2 parents 0a61c3b + f147993 commit a55a5db
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aws/resource_aws_cloudformation_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
22 changes: 22 additions & 0 deletions aws/resource_aws_cloudformation_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/cloudformation_stack.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


<a id="timeouts"></a>
## Timeouts

Expand Down

0 comments on commit a55a5db

Please sign in to comment.