diff --git a/builtin/providers/aws/import_aws_opsworks_stack_test.go b/builtin/providers/aws/import_aws_opsworks_stack_test.go new file mode 100644 index 000000000..40959346f --- /dev/null +++ b/builtin/providers/aws/import_aws_opsworks_stack_test.go @@ -0,0 +1,31 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSOpsworksStackImportBasic(t *testing.T) { + name := acctest.RandString(10) + + resourceName := "aws_opsworks_stack.tf-acc" + + 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, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_opsworks_stack.go b/builtin/providers/aws/resource_aws_opsworks_stack.go index 2d59e0734..a49e7cce2 100644 --- a/builtin/providers/aws/resource_aws_opsworks_stack.go +++ b/builtin/providers/aws/resource_aws_opsworks_stack.go @@ -20,6 +20,9 @@ func resourceAwsOpsworksStack() *schema.Resource { Read: resourceAwsOpsworksStackRead, Update: resourceAwsOpsworksStackUpdate, Delete: resourceAwsOpsworksStackDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "agent_version": &schema.Schema{ @@ -283,6 +286,9 @@ func resourceAwsOpsworksStackRead(d *schema.ResourceData, meta interface{}) erro d.Set("default_subnet_id", stack.DefaultSubnetId) d.Set("hostname_theme", stack.HostnameTheme) d.Set("use_custom_cookbooks", stack.UseCustomCookbooks) + if stack.CustomJson != nil { + d.Set("custom_json", stack.CustomJson) + } d.Set("use_opsworks_security_groups", stack.UseOpsworksSecurityGroups) d.Set("vpc_id", stack.VpcId) if color, ok := stack.Attributes["Color"]; ok { diff --git a/website/source/docs/import/importability.html.md b/website/source/docs/import/importability.html.md index d08fb6b67..9032250ad 100644 --- a/website/source/docs/import/importability.html.md +++ b/website/source/docs/import/importability.html.md @@ -67,6 +67,7 @@ To make a resource importable, please see the * aws_nat_gateway * aws_network_acl * aws_network_interface +* aws_opsworks_stack * aws_placement_group * aws_rds_cluster * aws_rds_cluster_instance diff --git a/website/source/docs/providers/aws/r/opsworks_stack.html.markdown b/website/source/docs/providers/aws/r/opsworks_stack.html.markdown index f1c6f978a..84e33c3d4 100644 --- a/website/source/docs/providers/aws/r/opsworks_stack.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_stack.html.markdown @@ -76,3 +76,12 @@ The `custom_cookbooks_source` block supports the following arguments: The following attributes are exported: * `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 +``` \ No newline at end of file