From 519f0ae4d6e3c9c7e83d9dc9e743127d6841db06 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 16 May 2016 10:26:49 -0700 Subject: [PATCH] providers/aws: launch configuration import --- .../import_aws_launch_configuration_test.go | 29 +++++++++++++++++++ .../aws/resource_aws_launch_configuration.go | 6 +++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 builtin/providers/aws/import_aws_launch_configuration_test.go diff --git a/builtin/providers/aws/import_aws_launch_configuration_test.go b/builtin/providers/aws/import_aws_launch_configuration_test.go new file mode 100644 index 000000000..f0a721a89 --- /dev/null +++ b/builtin/providers/aws/import_aws_launch_configuration_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSLaunchConfiguration_importBasic(t *testing.T) { + resourceName := "aws_launch_configuration.bar" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSLaunchConfigurationDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSLaunchConfigurationNoNameConfig, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"user_data"}, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_launch_configuration.go b/builtin/providers/aws/resource_aws_launch_configuration.go index 55256b9de..0dcbaaf70 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration.go +++ b/builtin/providers/aws/resource_aws_launch_configuration.go @@ -24,6 +24,9 @@ func resourceAwsLaunchConfiguration() *schema.Resource { Create: resourceAwsLaunchConfigurationCreate, Read: resourceAwsLaunchConfigurationRead, Delete: resourceAwsLaunchConfigurationDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -110,8 +113,8 @@ func resourceAwsLaunchConfiguration() *schema.Resource { "associate_public_ip_address": &schema.Schema{ Type: schema.TypeBool, Optional: true, + Computed: true, ForceNew: true, - Default: false, }, "spot_price": &schema.Schema{ @@ -495,6 +498,7 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{} d.Set("instance_type", lc.InstanceType) d.Set("name", lc.LaunchConfigurationName) + d.Set("associate_public_ip_address", lc.AssociatePublicIpAddress) d.Set("iam_instance_profile", lc.IamInstanceProfile) d.Set("ebs_optimized", lc.EbsOptimized) d.Set("spot_price", lc.SpotPrice)