我可以使用下面的方法获得负载均衡器
import boto3
elb = boto3.client('elbv2')
lbs = elb.describe_load_balancers()
如何获取实例lbs
.
另外,我如何获取状态不活动的负载均衡器,因为describe_load_balanacers仅给出状态active
负载平衡器。
经典负载均衡器
Use: client = boto3.client('elb')
Then describe_load_balancers() https://boto3.readthedocs.io/en/latest/reference/services/elb.html#ElasticLoadBalancing.Client.describe_load_balancers结果包括实例列表:
'Instances': [
{
'InstanceId': 'string'
},
],
应用程序负载均衡器
Use: client = boto3.client('elbv2')
- Call describe_target_groups() https://boto3.readthedocs.io/en/latest/reference/services/elbv2.html#ElasticLoadBalancingv2.Client.describe_target_groups传入负载均衡器ARN以获取列表目标群体与负载均衡器关联
- 然后打电话describe_target_health() https://boto3.readthedocs.io/en/latest/reference/services/elbv2.html#ElasticLoadBalancingv2.Client.describe_target_health获得一个目标清单(实例)。
以下是响应示例:
{
'TargetHealthDescriptions': [
{
'Target': {
'Id': 'i-0f76fade',
'Port': 80,
},
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)