Peter Lo
Peter Lo

Reputation: 85

Recreate AWS default subnets

I accidentally deleted all the default subnets in aws,I want to recreate default subnets。I make CLI command: "aws ec2 create-default-subnet --availability-zone us-west-2a" ,but always get the error message "An error occurred (DefaultSubnetAlreadyExistsInAvailabilityZone) when calling the CreateDefaultSubnet operation: 'subnet-015c449cab525d947' is already the default subnet in us-west-2d." how to solve this problem?

Upvotes: 2

Views: 1250

Answers (2)

Kavya Bhalodia
Kavya Bhalodia

Reputation: 31

To create default subnets, you need to use AWS CLI. Through AWS console you cannot create default subnets. Steps to create default subnet through AWS CLI:

  1. Download and install AWS CLI, if not present.
  2. Download Access keys of your AWS account(Click on account name and go to security credentials).
  3. Open cmd
  4. Write the command "aws configure".
  5. Enter all the credentials(Security credentials from the downloaded csv file).
  6. run the command "aws ec2 create-default-subnet --availability-zone us-east-2a" Write the region where you want to create default subnet instead of "us-east-2a"
  7. open aws account to view subnets

Upvotes: 3

majid Khatibshahidi
majid Khatibshahidi

Reputation: 141

There is only one default subnet can exist in each availability zone, seems you already have yours on us-west-2a, login to you AWS account search for VPC > Subnets and delete what you have there, then you can re-create it with this command: ws ec2 create-default-subnet --availability-zone us-west-2a

check AWS document fore more info: https://aws.amazon.com/premiumsupport/knowledge-center/recreate-default-vpc/

Upvotes: 3

Related Questions