Merge pull request #1518 from hashicorp/b-lc-id
providers/aws: set LC ID after creation
This commit is contained in:
commit
0eb69bcd37
|
@ -364,23 +364,25 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
||||||
createLaunchConfigurationOpts.BlockDeviceMappings = blockDevices
|
createLaunchConfigurationOpts.BlockDeviceMappings = blockDevices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var id string
|
||||||
if v, ok := d.GetOk("name"); ok {
|
if v, ok := d.GetOk("name"); ok {
|
||||||
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(v.(string))
|
id = v.(string)
|
||||||
d.SetId(d.Get("name").(string))
|
|
||||||
} else {
|
} else {
|
||||||
hash := sha1.Sum([]byte(fmt.Sprintf("%#v", createLaunchConfigurationOpts)))
|
hash := sha1.Sum([]byte(fmt.Sprintf("%#v", createLaunchConfigurationOpts)))
|
||||||
config_name := fmt.Sprintf("terraform-%s", base64.URLEncoding.EncodeToString(hash[:]))
|
configName := fmt.Sprintf("terraform-%s", base64.URLEncoding.EncodeToString(hash[:]))
|
||||||
log.Printf("[DEBUG] Computed Launch config name: %s", config_name)
|
log.Printf("[DEBUG] Computed Launch config name: %s", configName)
|
||||||
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(config_name)
|
id = configName
|
||||||
d.SetId(config_name)
|
|
||||||
}
|
}
|
||||||
|
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(id)
|
||||||
|
|
||||||
log.Printf("[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts)
|
log.Printf(
|
||||||
|
"[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts)
|
||||||
err := autoscalingconn.CreateLaunchConfiguration(&createLaunchConfigurationOpts)
|
err := autoscalingconn.CreateLaunchConfiguration(&createLaunchConfigurationOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating launch configuration: %s", err)
|
return fmt.Errorf("Error creating launch configuration: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.SetId(id)
|
||||||
log.Printf("[INFO] launch configuration ID: %s", d.Id())
|
log.Printf("[INFO] launch configuration ID: %s", d.Id())
|
||||||
|
|
||||||
// We put a Retry here since sometimes eventual consistency bites
|
// We put a Retry here since sometimes eventual consistency bites
|
||||||
|
|
Loading…
Reference in New Issue