Skip to content

Commit

Permalink
resource/aws_cloudformation_stack: Add support for Import
Browse files Browse the repository at this point in the history
Fixes: hashicorp#1331

```
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudFormation_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudFormation_ -timeout 120m
=== RUN   TestAccAWSCloudFormation_importBasic
--- PASS: TestAccAWSCloudFormation_importBasic (89.21s)
=== RUN   TestAccAWSCloudFormation_basic
--- PASS: TestAccAWSCloudFormation_basic (85.71s)
=== RUN   TestAccAWSCloudFormation_yaml
--- PASS: TestAccAWSCloudFormation_yaml (85.08s)
=== RUN   TestAccAWSCloudFormation_defaultParams
--- PASS: TestAccAWSCloudFormation_defaultParams (86.75s)
=== RUN   TestAccAWSCloudFormation_allAttributes
--- PASS: TestAccAWSCloudFormation_allAttributes (154.23s)
=== RUN   TestAccAWSCloudFormation_withParams
--- PASS: TestAccAWSCloudFormation_withParams (158.42s)
```
  • Loading branch information
stack72 committed Aug 16, 2017
1 parent e280538 commit f147993
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 f147993

Please sign in to comment.