简体   繁体   中英

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

I have the following AWS object ARN:

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

I need to check if the object exists using the AWS CLI. How to do it?

UPD

production-lambda-alb is elb of application type.

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

returns error:

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

however it isn't true as I can see the production-lambda-alb balancer in active state in aws console.

For Application and Network Load you have to use elbv2.

You can use the following cli:

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

If it exists it will return result, if not it will return the following:

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

Short answer - I had issue with elb . Following with elbv2 helped to list the available ELB ARNs -

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM