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" } ` diff --git a/website/source/docs/providers/aws/r/launch_config.html.markdown b/website/source/docs/providers/aws/r/launch_config.html.markdown index 4c697d9fa..3d6ff8373 100644 --- a/website/source/docs/providers/aws/r/launch_config.html.markdown +++ b/website/source/docs/providers/aws/r/launch_config.html.markdown @@ -27,10 +27,10 @@ The following arguments are supported: * `instance_type` - (Required) The size of instance to launch. * `key_name` - (Optional) The key name that should be used for the instance. * `security_groups` - (Optional) A list of associated security group IDS. +* `user_data` - (Optional) The user data to provide when launching the instance. ## Attributes Reference The following attributes are exported: * `id` - The ID of the launch configuration. -