func (lt *opsworksLayerType) Update(d *schema.ResourceData, client *opsworks.OpsWorks) error { req := &opsworks.UpdateLayerInput{ LayerId: aws.String(d.Id()), AutoAssignElasticIps: aws.Bool(d.Get("auto_assign_elastic_ips").(bool)), AutoAssignPublicIps: aws.Bool(d.Get("auto_assign_public_ips").(bool)), CustomInstanceProfileArn: aws.String(d.Get("custom_instance_profile_arn").(string)), CustomRecipes: lt.CustomRecipes(d), CustomSecurityGroupIds: makeAwsStringSet(d.Get("custom_security_group_ids").(*schema.Set)), EnableAutoHealing: aws.Bool(d.Get("auto_healing").(bool)), InstallUpdatesOnBoot: aws.Bool(d.Get("install_updates_on_boot").(bool)), LifecycleEventConfiguration: lt.LifecycleEventConfiguration(d), Name: aws.String(d.Get("name").(string)), Packages: makeAwsStringSet(d.Get("system_packages").(*schema.Set)), UseEbsOptimizedInstances: aws.Bool(d.Get("use_ebs_optimized_instances").(bool)), Attributes: lt.AttributeMap(d), VolumeConfigurations: lt.VolumeConfigurations(d), } if lt.CustomShortName { req.Shortname = aws.String(d.Get("short_name").(string)) } else { req.Shortname = aws.String(lt.TypeName) } log.Printf("[DEBUG] Updating OpsWorks layer: %s", d.Id()) if d.HasChange("elastic_load_balancer") { lbo, lbn := d.GetChange("elastic_load_balancer") loadBalancerOld := aws.String(lbo.(string)) loadBalancerNew := aws.String(lbn.(string)) if loadBalancerOld != nil && *loadBalancerOld != "" { log.Printf("[DEBUG] Dettaching load balancer: %s", *loadBalancerOld) _, err := client.DetachElasticLoadBalancer(&opsworks.DetachElasticLoadBalancerInput{ ElasticLoadBalancerName: loadBalancerOld, LayerId: aws.String(d.Id()), }) if err != nil { return err } } if loadBalancerNew != nil && *loadBalancerNew != "" { log.Printf("[DEBUG] Attaching load balancer: %s", *loadBalancerNew) client.AttachElasticLoadBalancer(&opsworks.AttachElasticLoadBalancerInput{ ElasticLoadBalancerName: loadBalancerNew, LayerId: aws.String(d.Id()), }) } } _, err := client.UpdateLayer(req) if err != nil { return err } return lt.Read(d, client) }
func (lt *opsworksLayerType) Update(d *schema.ResourceData, client *opsworks.OpsWorks) error { req := &opsworks.UpdateLayerInput{ LayerId: aws.String(d.Id()), AutoAssignElasticIps: aws.Bool(d.Get("auto_assign_elastic_ips").(bool)), AutoAssignPublicIps: aws.Bool(d.Get("auto_assign_public_ips").(bool)), CustomInstanceProfileArn: aws.String(d.Get("custom_instance_profile_arn").(string)), CustomRecipes: lt.CustomRecipes(d), CustomSecurityGroupIds: expandStringSet(d.Get("custom_security_group_ids").(*schema.Set)), EnableAutoHealing: aws.Bool(d.Get("auto_healing").(bool)), InstallUpdatesOnBoot: aws.Bool(d.Get("install_updates_on_boot").(bool)), LifecycleEventConfiguration: lt.LifecycleEventConfiguration(d), Name: aws.String(d.Get("name").(string)), Packages: expandStringSet(d.Get("system_packages").(*schema.Set)), UseEbsOptimizedInstances: aws.Bool(d.Get("use_ebs_optimized_instances").(bool)), Attributes: lt.AttributeMap(d), VolumeConfigurations: lt.VolumeConfigurations(d), } if lt.CustomShortName { req.Shortname = aws.String(d.Get("short_name").(string)) } else { req.Shortname = aws.String(lt.TypeName) } log.Printf("[DEBUG] Updating OpsWorks layer: %s", d.Id()) _, err := client.UpdateLayer(req) if err != nil { return err } return lt.Read(d, client) }