Valeri
Valeri

Reputation: 1142

How to get available subnets from AWS VPC?

I am trying to create an Application Load Balancer using AWS CLI. create-load-balancer

The error message is as follows:
An error occurred (ValidationError) when calling the CreateLoadBalancer operation: At least two subnets in two different Availability Zones must be specified

So I need to get available subnets from a specific zone (ex: us-east-2). How can I get the all available subnets using AWS CLI?

Upvotes: 0

Views: 2339

Answers (1)

Ahmed Galal
Ahmed Galal

Reputation: 73

In order to create a new Application Load Balancer you should use the following CLI Command:

aws elbv2 create-load-balancer --name my-load-balancer --subnets SUBNET_1 SUBNET_2

You can get the list of available subnets by analyzing your VPC. To do this please follow these steps:

  • Open your AWS Console
  • Navigate to VPC
  • Open Subnets section on the left
  • Get the subnets that are linked to your VPC and make sure that you have two subnets in two different availability zones. If you don't have then please create them
  • Use these subnets with the above CLI command

If you don't have console access for any reason then use this command to get the list of available subnets from the CLI:

aws ec2 describe-subnets

Upvotes: 1

Related Questions