provider/aws: Fix issue with Launch Configurations and enable_monitoring

Can now set this value to false. Fixes #2734
This commit is contained in:
Clint Shryock 2015-07-15 10:42:39 -05:00
parent abe62e635a
commit 1091884735

View File

@ -118,8 +118,8 @@ func resourceAwsLaunchConfiguration() *schema.Resource {
"enable_monitoring": &schema.Schema{ "enable_monitoring": &schema.Schema{
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
Computed: true,
ForceNew: true, ForceNew: true,
Default: true,
}, },
"ebs_block_device": &schema.Schema{ "ebs_block_device": &schema.Schema{
@ -272,10 +272,8 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
createLaunchConfigurationOpts.UserData = aws.String(userData) createLaunchConfigurationOpts.UserData = aws.String(userData)
} }
if v, ok := d.GetOk("enable_monitoring"); ok {
createLaunchConfigurationOpts.InstanceMonitoring = &autoscaling.InstanceMonitoring{ createLaunchConfigurationOpts.InstanceMonitoring = &autoscaling.InstanceMonitoring{
Enabled: aws.Boolean(v.(bool)), Enabled: aws.Boolean(d.Get("enable_monitoring").(bool)),
}
} }
if v, ok := d.GetOk("iam_instance_profile"); ok { if v, ok := d.GetOk("iam_instance_profile"); ok {
@ -394,7 +392,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(lcName) createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(lcName)
log.Printf( log.Printf(
"[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts) "[DEBUG] autoscaling create launch configuration: %s", createLaunchConfigurationOpts)
// IAM profiles can take ~10 seconds to propagate in AWS: // IAM profiles can take ~10 seconds to propagate in AWS:
// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console
@ -435,7 +433,7 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{}
LaunchConfigurationNames: []*string{aws.String(d.Id())}, LaunchConfigurationNames: []*string{aws.String(d.Id())},
} }
log.Printf("[DEBUG] launch configuration describe configuration: %#v", describeOpts) log.Printf("[DEBUG] launch configuration describe configuration: %s", describeOpts)
describConfs, err := autoscalingconn.DescribeLaunchConfigurations(&describeOpts) describConfs, err := autoscalingconn.DescribeLaunchConfigurations(&describeOpts)
if err != nil { if err != nil {
return fmt.Errorf("Error retrieving launch configuration: %s", err) return fmt.Errorf("Error retrieving launch configuration: %s", err)