diff --git a/builtin/providers/aws/import_aws_opsworks_custom_layer_test.go b/builtin/providers/aws/import_aws_opsworks_custom_layer_test.go new file mode 100644 index 000000000..0911cdf39 --- /dev/null +++ b/builtin/providers/aws/import_aws_opsworks_custom_layer_test.go @@ -0,0 +1,31 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSOpsworksCustomLayerImportBasic(t *testing.T) { + name := acctest.RandString(10) + + resourceName := "aws_opsworks_custom_layer.tf-acc" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsOpsworksCustomLayerDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAwsOpsworksCustomLayerConfigVpcCreate(name), + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/builtin/providers/aws/opsworks_layers.go b/builtin/providers/aws/opsworks_layers.go index 75eed16c0..c4bfeb6b2 100644 --- a/builtin/providers/aws/opsworks_layers.go +++ b/builtin/providers/aws/opsworks_layers.go @@ -251,6 +251,9 @@ func (lt *opsworksLayerType) SchemaResource() *schema.Resource { client := meta.(*AWSClient).opsworksconn return lt.Delete(d, client) }, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: resourceSchema, } diff --git a/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go b/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go index 4df719484..67c6d8a7a 100644 --- a/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go +++ b/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go @@ -23,7 +23,7 @@ func TestAccAWSOpsworksCustomLayer(t *testing.T) { CheckDestroy: testAccCheckAwsOpsworksCustomLayerDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAwsOpsworksCustomLayerConfigCreate(stackName), + Config: testAccAwsOpsworksCustomLayerConfigNoVpcCreate(stackName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "aws_opsworks_custom_layer.tf-acc", "name", stackName, @@ -187,7 +187,7 @@ resource "aws_security_group" "tf-ops-acc-layer2" { }`, name, name) } -func testAccAwsOpsworksCustomLayerConfigCreate(name string) string { +func testAccAwsOpsworksCustomLayerConfigNoVpcCreate(name string) string { return fmt.Sprintf(` provider "aws" { region = "us-east-1" @@ -224,6 +224,43 @@ resource "aws_opsworks_custom_layer" "tf-acc" { `, name, testAccAwsOpsworksStackConfigNoVpcCreate(name), testAccAwsOpsworksCustomLayerSecurityGroups(name)) } +func testAccAwsOpsworksCustomLayerConfigVpcCreate(name string) string { + return fmt.Sprintf(` +provider "aws" { + region = "us-west-2" +} + +resource "aws_opsworks_custom_layer" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + name = "%s" + short_name = "tf-ops-acc-custom-layer" + auto_assign_public_ips = false + custom_security_group_ids = [ + "${aws_security_group.tf-ops-acc-layer1.id}", + "${aws_security_group.tf-ops-acc-layer2.id}", + ] + drain_elb_on_shutdown = true + instance_shutdown_timeout = 300 + system_packages = [ + "git", + "golang", + ] + ebs_volume { + type = "gp2" + number_of_disks = 2 + mount_point = "/home" + size = 100 + raid_level = 0 + } +} + +%s + +%s + +`, name, testAccAwsOpsworksStackConfigVpcCreate(name), testAccAwsOpsworksCustomLayerSecurityGroups(name)) +} + func testAccAwsOpsworksCustomLayerConfigUpdate(name string) string { return fmt.Sprintf(` provider "aws" { diff --git a/builtin/providers/aws/resource_aws_opsworks_stack.go b/builtin/providers/aws/resource_aws_opsworks_stack.go index a49e7cce2..c88b910ba 100644 --- a/builtin/providers/aws/resource_aws_opsworks_stack.go +++ b/builtin/providers/aws/resource_aws_opsworks_stack.go @@ -338,6 +338,9 @@ func resourceAwsOpsworksStackCreate(d *schema.ResourceData, meta interface{}) er if defaultAvailabilityZone, ok := d.GetOk("default_availability_zone"); ok { req.DefaultAvailabilityZone = aws.String(defaultAvailabilityZone.(string)) } + if defaultRootDeviceType, ok := d.GetOk("default_root_device_type"); ok { + req.DefaultRootDeviceType = aws.String(defaultRootDeviceType.(string)) + } log.Printf("[DEBUG] Creating OpsWorks stack: %s", req) diff --git a/website/source/docs/import/importability.html.md b/website/source/docs/import/importability.html.md index 795c7757b..2d6e1bd9c 100644 --- a/website/source/docs/import/importability.html.md +++ b/website/source/docs/import/importability.html.md @@ -68,6 +68,7 @@ To make a resource importable, please see the * aws_nat_gateway * aws_network_acl * aws_network_interface +* aws_opsworks_custom_layer * aws_opsworks_stack * aws_placement_group * aws_rds_cluster diff --git a/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown index b43ce8a2d..887c1bcca 100644 --- a/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown @@ -65,3 +65,12 @@ An `ebs_volume` block supports the following arguments: The following attributes are exported: * `id` - The id of the layer. + + +## Import + +OpsWorks Custom Layers can be imported using the `id`, e.g. + +``` +$ terraform import aws_opsworks_custom_layer.bar 00000000-0000-0000-0000-000000000000 +``` \ No newline at end of file