如何使用 AWS CLI 和对象 ARN 检查 AWS 对象是否存在?

How to check if the AWS object exists using AWS CLI and object ARN?

我有以下 AWS 对象 ARN:

arn:aws:elasticloadbalancing:us-west-2:xxxxxxxx:loadbalancer/app/production-lambda-alb/yyyyyyyyyyyy

我需要使用 AWS CLI 检查对象是否存在。怎么做?

UPD

production-lambda-albelb 的应用程序类型。

aws elb describe-load-balancers --load-balancer-names production-lambda-alb

returns 错误:

An error occurred (LoadBalancerNotFound) when calling the DescribeLoadBalancers operation: There is no ACTIVE Load Balancer named 'production-lambda-alb'

但这不是真的,因为我可以在 aws 控制台中看到 production-lambda-alb 平衡器处于活动状态。

对于应用程序和网络负载,您必须使用 elbv2。

您可以使用以下cli:

aws elbv2 describe-load-balancers --load-balancer-arns arn:aws:elasticloadbalancing:us-west-2:xxxxxxxx:loadbalancer/app/production-lambda-alb/yyyyyyyyyyyy

如果它存在,它将 return 结果,如果不存在,它将 return 以下内容:

An error occurred (LoadBalancerNotFound) when calling the DescribeLoadBalancers operation: One or more load balancers not found

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elbv2/describe-load-balancers.html

简答 - 我对 elb 有疑问。跟随 elbv2 有助于列出可用的 ELB ARN -

aws \
--profile AWS_PROFILE_NAME \
--region AWS_REGION \
elbv2 \
describe-load-balancers \
--query 'LoadBalancers[].LoadBalancerArn' --output text