如何通过 boto3 在 AWS 中查找所有使用特定 VPC 的 ELB 名称?
How to find all ELB name that are using specific VPC in AWS via boto3?
我想使用 boto3 过滤和列出具有特定 vpcid 的 ELB。使用那个 ELB 名称,我想使用 boto3
删除那个 ELB
它会是这样的:
import boto3
client = boto3.client('elbv2', region="ap_southeast_2")
response = client.describe_load_balancers()
# Get ELBs
for elb in response['LoadBalancers']:
if elb['VpcId'] == 'vpc-xxx':
# Delete ELB
client.delete_load_balancer(LoadBalancerArn=elb['LoadBalancerArn'])
import boto3
elb_client = boto3.client('elbv2', region="us-west-2")
elbs = elb_client.describe_load_balancers()['LoadBalancers']
elbs = [elb['LoadBalancerArn'] for elb in elbs if elb['VpcId'] == 'vpc-xxxxxxxx']
for elb in elbs:
elb_client.delete_load_balancer(LoadBalancerArn=elb)
我想使用 boto3 过滤和列出具有特定 vpcid 的 ELB。使用那个 ELB 名称,我想使用 boto3
删除那个 ELB它会是这样的:
import boto3
client = boto3.client('elbv2', region="ap_southeast_2")
response = client.describe_load_balancers()
# Get ELBs
for elb in response['LoadBalancers']:
if elb['VpcId'] == 'vpc-xxx':
# Delete ELB
client.delete_load_balancer(LoadBalancerArn=elb['LoadBalancerArn'])
import boto3
elb_client = boto3.client('elbv2', region="us-west-2")
elbs = elb_client.describe_load_balancers()['LoadBalancers']
elbs = [elb['LoadBalancerArn'] for elb in elbs if elb['VpcId'] == 'vpc-xxxxxxxx']
for elb in elbs:
elb_client.delete_load_balancer(LoadBalancerArn=elb)