From 15bdf8b5f93c0f748a4bfd1032cb87585ca5b91f Mon Sep 17 00:00:00 2001 From: Luke Chadwick Date: Wed, 30 Jul 2014 07:30:24 +1000 Subject: [PATCH] Add user_data to aws_launch_configuration --- .../providers/aws/resource_aws_launch_configuration.go | 6 ++++++ .../aws/resource_aws_launch_configuration_test.go | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/builtin/providers/aws/resource_aws_launch_configuration.go b/builtin/providers/aws/resource_aws_launch_configuration.go index bc6997ed3..e3a7a03d3 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration.go +++ b/builtin/providers/aws/resource_aws_launch_configuration.go @@ -50,6 +50,10 @@ func resource_aws_launch_configuration_create( rs.Attributes, "security_groups").([]interface{})) } + if rs.Attributes["user_data"] != "" { + createLaunchConfigurationOpts.UserData = rs.Attributes["user_data"] + } + createLaunchConfigurationOpts.Name = rs.Attributes["name"] log.Printf("[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts) @@ -128,6 +132,7 @@ func resource_aws_launch_configuration_diff( "key_name": diff.AttrTypeCreate, "name": diff.AttrTypeCreate, "security_groups": diff.AttrTypeCreate, + "user_data": diff.AttrTypeCreate, }, ComputedAttrs: []string{ @@ -198,6 +203,7 @@ func resource_aws_launch_configuration_validation() *config.Validator { Optional: []string{ "key_name", "security_groups.*", + "user_data", }, } } diff --git a/builtin/providers/aws/resource_aws_launch_configuration_test.go b/builtin/providers/aws/resource_aws_launch_configuration_test.go index 2126671b6..38b03c36b 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration_test.go +++ b/builtin/providers/aws/resource_aws_launch_configuration_test.go @@ -3,6 +3,7 @@ package aws import ( "fmt" "testing" + "bytes" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -28,6 +29,8 @@ func TestAccAWSLaunchConfiguration(t *testing.T) { "aws_launch_configuration.bar", "name", "foobar-terraform-test"), resource.TestCheckResourceAttr( "aws_launch_configuration.bar", "instance_type", "t1.micro"), + resource.TestCheckResourceAttr( + "aws_launch_configuration.bar", "user_data", "foobar-user-data"), ), }, }, @@ -81,6 +84,10 @@ func testAccCheckAWSLaunchConfigurationAttributes(conf *autoscaling.LaunchConfig return fmt.Errorf("Bad instance_type: %s", conf.InstanceType) } + if ! bytes.Equal(conf.UserData, []byte("foobar-user-data")) { + return fmt.Errorf("Bad user_data: %s", conf.UserData) + } + return nil } } @@ -123,5 +130,6 @@ resource "aws_launch_configuration" "bar" { name = "foobar-terraform-test" image_id = "ami-fb8e9292" instance_type = "t1.micro" + user_data = "foobar-user-data" } `