本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/autoscaling.AutoScaling.EnableMetricsCollection方法的典型用法代碼示例。如果您正苦於以下問題:Golang AutoScaling.EnableMetricsCollection方法的具體用法?Golang AutoScaling.EnableMetricsCollection怎麽用?Golang AutoScaling.EnableMetricsCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/aws-sdk-go/service/autoscaling.AutoScaling
的用法示例。
在下文中一共展示了AutoScaling.EnableMetricsCollection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: enableASGMetricsCollection
func enableASGMetricsCollection(d *schema.ResourceData, conn *autoscaling.AutoScaling) error {
props := &autoscaling.EnableMetricsCollectionInput{
AutoScalingGroupName: aws.String(d.Id()),
Granularity: aws.String(d.Get("metrics_granularity").(string)),
Metrics: expandStringList(d.Get("enabled_metrics").(*schema.Set).List()),
}
log.Printf("[INFO] Enabling metrics collection for the ASG: %s", d.Id())
_, metricsErr := conn.EnableMetricsCollection(props)
if metricsErr != nil {
return metricsErr
}
return nil
}
示例2: updateASGMetricsCollection
func updateASGMetricsCollection(d *schema.ResourceData, conn *autoscaling.AutoScaling) error {
o, n := d.GetChange("enabled_metrics")
if o == nil {
o = new(schema.Set)
}
if n == nil {
n = new(schema.Set)
}
os := o.(*schema.Set)
ns := n.(*schema.Set)
disableMetrics := os.Difference(ns)
if disableMetrics.Len() != 0 {
props := &autoscaling.DisableMetricsCollectionInput{
AutoScalingGroupName: aws.String(d.Id()),
Metrics: expandStringList(disableMetrics.List()),
}
_, err := conn.DisableMetricsCollection(props)
if err != nil {
return fmt.Errorf("Failure to Disable metrics collection types for ASG %s: %s", d.Id(), err)
}
}
enabledMetrics := ns.Difference(os)
if enabledMetrics.Len() != 0 {
props := &autoscaling.EnableMetricsCollectionInput{
AutoScalingGroupName: aws.String(d.Id()),
Metrics: expandStringList(enabledMetrics.List()),
Granularity: aws.String(d.Get("metrics_granularity").(string)),
}
_, err := conn.EnableMetricsCollection(props)
if err != nil {
return fmt.Errorf("Failure to Enable metrics collection types for ASG %s: %s", d.Id(), err)
}
}
return nil
}