Add ability to import OpsWorks stacks
This commit is contained in:
parent
88c3554dda
commit
1bc154535f
|
@ -0,0 +1,36 @@
|
||||||
|
package aws
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccAWSOpsWorksStack_importBasic(t *testing.T) {
|
||||||
|
oldvar := os.Getenv("AWS_DEFAULT_REGION")
|
||||||
|
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
|
||||||
|
defer os.Setenv("AWS_DEFAULT_REGION", oldvar)
|
||||||
|
|
||||||
|
name := acctest.RandString(10)
|
||||||
|
|
||||||
|
resourceName := "aws_opsworks_stack.bar"
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckAwsOpsworksStackDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAwsOpsworksStackConfigVpcCreate(name),
|
||||||
|
},
|
||||||
|
|
||||||
|
resource.TestStep{
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -20,6 +20,9 @@ func resourceAwsOpsworksStack() *schema.Resource {
|
||||||
Read: resourceAwsOpsworksStackRead,
|
Read: resourceAwsOpsworksStackRead,
|
||||||
Update: resourceAwsOpsworksStackUpdate,
|
Update: resourceAwsOpsworksStackUpdate,
|
||||||
Delete: resourceAwsOpsworksStackDelete,
|
Delete: resourceAwsOpsworksStackDelete,
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: schema.ImportStatePassthrough,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"agent_version": &schema.Schema{
|
"agent_version": &schema.Schema{
|
||||||
|
|
|
@ -67,6 +67,7 @@ To make a resource importable, please see the
|
||||||
* aws_nat_gateway
|
* aws_nat_gateway
|
||||||
* aws_network_acl
|
* aws_network_acl
|
||||||
* aws_network_interface
|
* aws_network_interface
|
||||||
|
* aws_opsworks_stack
|
||||||
* aws_placement_group
|
* aws_placement_group
|
||||||
* aws_rds_cluster
|
* aws_rds_cluster
|
||||||
* aws_rds_cluster_instance
|
* aws_rds_cluster_instance
|
||||||
|
|
|
@ -76,3 +76,12 @@ The `custom_cookbooks_source` block supports the following arguments:
|
||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
|
||||||
* `id` - The id of the stack.
|
* `id` - The id of the stack.
|
||||||
|
|
||||||
|
|
||||||
|
## Import
|
||||||
|
|
||||||
|
OpsWorks stacks can be imported using the `id`, e.g.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ terraform import aws_opsworks_stack.bar 00000000-0000-0000-0000-000000000000
|
||||||
|
```
|
Loading…
Reference in New Issue