func getAwsAutoscalingPutLifecycleHookInput(d *schema.ResourceData) autoscaling.PutLifecycleHookInput { var params = autoscaling.PutLifecycleHookInput{ AutoScalingGroupName: aws.String(d.Get("autoscaling_group_name").(string)), LifecycleHookName: aws.String(d.Get("name").(string)), } if v, ok := d.GetOk("default_result"); ok { params.DefaultResult = aws.String(v.(string)) } if v, ok := d.GetOk("heartbeat_timeout"); ok { params.HeartbeatTimeout = aws.Int64(int64(v.(int))) } if v, ok := d.GetOk("lifecycle_transition"); ok { params.LifecycleTransition = aws.String(v.(string)) } if v, ok := d.GetOk("notification_metadata"); ok { params.NotificationMetadata = aws.String(v.(string)) } if v, ok := d.GetOk("notification_target_arn"); ok { params.NotificationTargetARN = aws.String(v.(string)) } if v, ok := d.GetOk("role_arn"); ok { params.RoleARN = aws.String(v.(string)) } return params }
func generatePutLifecycleHookInputs(asgName string, cfgs []interface{}) []autoscaling.PutLifecycleHookInput { res := make([]autoscaling.PutLifecycleHookInput, 0, len(cfgs)) for _, raw := range cfgs { cfg := raw.(map[string]interface{}) input := autoscaling.PutLifecycleHookInput{ AutoScalingGroupName: &asgName, LifecycleHookName: aws.String(cfg["name"].(string)), } if v, ok := cfg["default_result"]; ok && v.(string) != "" { input.DefaultResult = aws.String(v.(string)) } if v, ok := cfg["heartbeat_timeout"]; ok && v.(int) > 0 { input.HeartbeatTimeout = aws.Int64(int64(v.(int))) } if v, ok := cfg["lifecycle_transition"]; ok && v.(string) != "" { input.LifecycleTransition = aws.String(v.(string)) } if v, ok := cfg["notification_metadata"]; ok && v.(string) != "" { input.NotificationMetadata = aws.String(v.(string)) } if v, ok := cfg["notification_target_arn"]; ok && v.(string) != "" { input.NotificationTargetARN = aws.String(v.(string)) } if v, ok := cfg["role_arn"]; ok && v.(string) != "" { input.RoleARN = aws.String(v.(string)) } res = append(res, input) } return res }