AttributeError: 'ElasticLoadBalancingv2' object has no attribute 'set_desired_capacity'
AttributeError: 'ElasticLoadBalancingv2' object has no attribute 'set_desired_capacity'
import boto3
import json
import time
client = boto3.client('elbv2')
desired_capacity=8
client.set_desired_capacity(
AutoScalingGroupName='Test-Web',
DesiredCapacity=desired_capacity,
HonorCooldown=True)
和
boto3==1.7.1
当我 运行 这个脚本时,我得到一个
File "deploy_staging_web.py", line 6, in <module>
client.set_desired_capacity(
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 601, in __getattr__
self.__class__.__name__, item)
AttributeError: 'ElasticLoadBalancingv2' object has no attribute 'set_desired_capacity'
我打算使用 python 来扩展和缩小 aws 实例。
我目前不在任何虚拟环境中。
为什么会抛出它,我该如何克服它?
它甚至在官方文档中提到:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.set_desired_capacity
官方文档是针对最新版本的,不是你太旧的版本。将您的 boto3
软件包升级到最新版本。最新版本是 1.9.243。
这个问题原来是个傻问题。
boto3 已经移动了各种功能。
set_desired_capacity 不再是 'elbv2' 的一部分。
它是 'autoscaling' https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.set_desired_capacity
的一部分
而'describe_target_health'仍然是前https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elbv2.html?highlight=elb#ElasticLoadBalancingv2.Client.describe_target_health的一部分。
正在更新
client = boto3.client('elbv2')
到
client = boto3.client('autoscaling')
解决了我的问题。
import boto3
import json
import time
client = boto3.client('elbv2')
desired_capacity=8
client.set_desired_capacity(
AutoScalingGroupName='Test-Web',
DesiredCapacity=desired_capacity,
HonorCooldown=True)
和 boto3==1.7.1
当我 运行 这个脚本时,我得到一个
File "deploy_staging_web.py", line 6, in <module>
client.set_desired_capacity(
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 601, in __getattr__
self.__class__.__name__, item)
AttributeError: 'ElasticLoadBalancingv2' object has no attribute 'set_desired_capacity'
我打算使用 python 来扩展和缩小 aws 实例。
我目前不在任何虚拟环境中。
为什么会抛出它,我该如何克服它? 它甚至在官方文档中提到:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.set_desired_capacity
官方文档是针对最新版本的,不是你太旧的版本。将您的 boto3
软件包升级到最新版本。最新版本是 1.9.243。
这个问题原来是个傻问题。
boto3 已经移动了各种功能。
set_desired_capacity 不再是 'elbv2' 的一部分。
它是 'autoscaling' https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.set_desired_capacity
而'describe_target_health'仍然是前https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elbv2.html?highlight=elb#ElasticLoadBalancingv2.Client.describe_target_health的一部分。
正在更新
client = boto3.client('elbv2')
到
client = boto3.client('autoscaling')
解决了我的问题。