Merge pull request #94 from vertis/add_user_data_to_aws_launch_configuration
Add user data to aws launch configuration
This commit is contained in:
commit
3535ae36a3
|
@ -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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue