本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/autoscaling.CreateAutoScalingGroupInput.TargetGroupARNs方法的典型用法代码示例。如果您正苦于以下问题:Golang CreateAutoScalingGroupInput.TargetGroupARNs方法的具体用法?Golang CreateAutoScalingGroupInput.TargetGroupARNs怎么用?Golang CreateAutoScalingGroupInput.TargetGroupARNs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/autoscaling.CreateAutoScalingGroupInput
的用法示例。
在下文中一共展示了CreateAutoScalingGroupInput.TargetGroupARNs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resourceAwsAutoscalingGroupCreate
func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).autoscalingconn
var asgName string
if v, ok := d.GetOk("name"); ok {
asgName = v.(string)
} else {
asgName = resource.PrefixedUniqueId("tf-asg-")
d.Set("name", asgName)
}
createOpts := autoscaling.CreateAutoScalingGroupInput{
AutoScalingGroupName: aws.String(asgName),
LaunchConfigurationName: aws.String(d.Get("launch_configuration").(string)),
NewInstancesProtectedFromScaleIn: aws.Bool(d.Get("protect_from_scale_in").(bool)),
}
updateOpts := autoscaling.UpdateAutoScalingGroupInput{
AutoScalingGroupName: aws.String(asgName),
}
initialLifecycleHooks := d.Get("initial_lifecycle_hook").(*schema.Set).List()
twoPhases := len(initialLifecycleHooks) > 0
minSize := aws.Int64(int64(d.Get("min_size").(int)))
maxSize := aws.Int64(int64(d.Get("max_size").(int)))
if twoPhases {
createOpts.MinSize = aws.Int64(int64(0))
createOpts.MaxSize = aws.Int64(int64(0))
updateOpts.MinSize = minSize
updateOpts.MaxSize = maxSize
if v, ok := d.GetOk("desired_capacity"); ok {
updateOpts.DesiredCapacity = aws.Int64(int64(v.(int)))
}
} else {
createOpts.MinSize = minSize
createOpts.MaxSize = maxSize
if v, ok := d.GetOk("desired_capacity"); ok {
createOpts.DesiredCapacity = aws.Int64(int64(v.(int)))
}
}
// Availability Zones are optional if VPC Zone Identifer(s) are specified
if v, ok := d.GetOk("availability_zones"); ok && v.(*schema.Set).Len() > 0 {
createOpts.AvailabilityZones = expandStringList(v.(*schema.Set).List())
}
if v, ok := d.GetOk("tag"); ok {
createOpts.Tags = autoscalingTagsFromMap(
setToMapByKey(v.(*schema.Set), "key"), d.Get("name").(string))
}
if v, ok := d.GetOk("default_cooldown"); ok {
createOpts.DefaultCooldown = aws.Int64(int64(v.(int)))
}
if v, ok := d.GetOk("health_check_type"); ok && v.(string) != "" {
createOpts.HealthCheckType = aws.String(v.(string))
}
if v, ok := d.GetOk("health_check_grace_period"); ok {
createOpts.HealthCheckGracePeriod = aws.Int64(int64(v.(int)))
}
if v, ok := d.GetOk("placement_group"); ok {
createOpts.PlacementGroup = aws.String(v.(string))
}
if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 {
createOpts.LoadBalancerNames = expandStringList(
v.(*schema.Set).List())
}
if v, ok := d.GetOk("vpc_zone_identifier"); ok && v.(*schema.Set).Len() > 0 {
createOpts.VPCZoneIdentifier = expandVpcZoneIdentifiers(v.(*schema.Set).List())
}
if v, ok := d.GetOk("termination_policies"); ok && len(v.([]interface{})) > 0 {
createOpts.TerminationPolicies = expandStringList(v.([]interface{}))
}
if v, ok := d.GetOk("target_group_arns"); ok && len(v.(*schema.Set).List()) > 0 {
createOpts.TargetGroupARNs = expandStringList(v.(*schema.Set).List())
}
log.Printf("[DEBUG] AutoScaling Group create configuration: %#v", createOpts)
_, err := conn.CreateAutoScalingGroup(&createOpts)
if err != nil {
return fmt.Errorf("Error creating AutoScaling Group: %s", err)
}
d.SetId(d.Get("name").(string))
log.Printf("[INFO] AutoScaling Group ID: %s", d.Id())
if twoPhases {
for _, hook := range generatePutLifecycleHookInputs(asgName, initialLifecycleHooks) {
if err = resourceAwsAutoscalingLifecycleHookPutOp(conn, &hook); err != nil {
//.........这里部分代码省略.........