简体   繁体   English

如何从AWS VPC获取可用子网?

[英]How to get available subnets from AWS VPC?

I am trying to create an Application Load Balancer using AWS CLI. 我正在尝试使用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). 因此,我需要从特定区域(例如:us-east-2)获取可用的子网。 How can I get the all available subnets using AWS CLI? 如何使用AWS CLI获取所有可用的子网?

In order to create a new Application Load Balancer you should use the following CLI Command: 为了创建新的应用程序负载平衡器,您应该使用以下CLI命令:

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. 您可以通过分析VPC来获取可用子网的列表。 To do this please follow these steps: 为此,请按照下列步骤操作:

  • Open your AWS Console 打开您的AWS控制台
  • Navigate to VPC 导航到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. 获取链接到VPC的子网,并确保在两个不同的可用区域中有两个子网。 If you don't have then please create them 如果没有,请创建它们
  • Use these subnets with the above CLI command 将这些子网与上面的CLI命令一起使用

If you don't have console access for any reason then use this command to get the list of available subnets from the CLI: 如果由于某种原因没有控制台访问权限,请使用以下命令从CLI获取可用子网的列表:

aws ec2 describe-subnets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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