How to get available subnets from AWS VPC? - amazon-web-services

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?

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

Related

Access AWS EFS from two different VPC's in same account

I have an EFS file system. I have created two mounts one for us-east-1a and another for us-east-1b and both are in the same VPC. Now I have a requirement to add a mount point and it's in a different VPC but in the same account. When I try to create the mount target I get the below error
aws efs create-mount-target --file-system-id fs-abcdef --subnet-id subnet-156fd195808k8l --security-groups sg-99b88u518a368dp
An error occurred (MountTargetConflict) when calling the CreateMountTarget operation: requested subnet for new mount target is not in the same VPC as existing mount targets
is there a way I can use the EFS in two different VPCs?
VPC peering OR Transit Gateway is enough in order for NFS client from different VPC to connect to EFS in separate VPC.
Only one mount target for a certain EFS is needed per AZ. The error shows that you already have mount target for the specific EFS.
To connect your NFS client you can follow the AWS provide documentation

Cannot create ElasticBeanstalk app with Network Load Balancer using CLI with an organization granted account

I'm trying to create Beanstalk app with Network load balancer in new VPC (one public, one private subnet, internet gateway, nat gateway...)
I can create successfully in my personal aws account.
With account of my organization, I have this error "VPC does not exist":
eb create Dev-Price-Availability-API-App-Dev -i t2.micro --vpc --vpc.id vpc-e753b89d
Do you want to associate a public IP address? (Y/n): n
Enter a comma-separated list of Amazon EC2 subnets: subnet-2903f417
Enter a comma-separated list of Amazon ELB subnets: subnet-2903f417
Enter a comma-separated list of Amazon VPC security groups: sg-c382d588
Do you want the load balancer to be public? (Select no for internal) (Y/n): n
NOTE: The current directory does not contain any source code. Elastic Beanstalk is launching the sample application instead.
ERROR: ServiceError - Configuration validation exception: The VPC 'vpc-e753b89d' does not exist.
I try to reproduce many times (create new VPC...), and the script always run successfully in my personal AWS but having the same error in organization AWS. All subnet of vpc and beanstalk are in the same region (us-east-1).
Sometimes, the script throws "subnet does not exist", "securitygroups does not exists"
Does anyone have the same issue, could you give me some ideas?
I think there is a bug from EB CLI. Currently I use: EB CLI 3.14.1 (Python 3.6.5).
When I run eb cli, eb always take my default aws profile even though I set aws profile to my organization profile.
[default]
region=us-west-2
aws_access_key_id=....
aws_secret_access_key=...
[myorganization]
aws_access_key_id=...
aws_secret_access_key=...
region=us-east-1
output=json
So the way I did is:
- Backup my default profile
- Rename my organization profile to default
Then I can run eb command successfuly without error.
Thanks

LaunchWaitCondition failed. The expected number of EC2 instances were not initialized within the given time

The error message is:
Stack named 'awseb-e-r3uhxvhyz7-stack' aborted operation. Current state: 'CREATE_FAILED' Reason: The following resource(s) failed to create: [AWSEBInstanceLaunchWaitCondition].
I am trying to use Multi-Container Docker in AWS Elastic Beanstalk.
Can someone help me to get rid of this error.Is it necessary to use more than one EC2 instance for using Multi-Container Docker in AWS Elastic Beanstalk?
This sound kinda what your issue is:
If you use Amazon VPC with Elastic Beanstalk, Amazon EC2 instances deployed in a private subnet cannot communicate directly with the Internet. Amazon EC2 instances must have Internet connectivity to communicate to Elastic Beanstalk that they were successfully launched. To provide EC2 instances in a private subnet with Internet connectivity, you must add a load balancer and NAT to the public subnet. You must create the appropriate routing rules for inbound and outbound traffic through the load balancer and NAT. You must also configure the default Amazon VPC security group to allow traffic from the Amazon EC2 instances to the NAT instance.
Source: Amazon EC2 Instances Fail to Launch within the Wait Period
I've fixed this. It looks the like IAM role created by default for the single docker EB deployment didn't contain the necessary ECS Policy (unconfirmed).
I followed the instructions to create a policy to add the role and everyhing worked.

Unable to add EC2 instance to load balancer on AWS

This seems like an easy step in the process, but I've been left scratching my head.
I am setting up an elastic load balancer on AWS, however when I get to the step to add EC2 instances, it does not list all of the instances I am running. I attempted to add the instance to the load balancer using the AWS command line, but received this message:
aws elb register-instances-with-load-balancer --load-balancer-name Simply --instances instance-id
Invalid endpoint: https://elasticloadbalancing.N. Virginia.amazonaws.com
Any ideas?
You have incorrectly set the region to be N. Virginia in the CLI configuration.
It should be: us-east-1
For a list of region names see: Regions and Endpoints

Amazon VPC Availability

We are trying to expand our reliability setup using VPC in us-west-1. The 'a' and 'b' AZs work fine, but when I try to create subnets on 'c' it just fails with the message:
Value (us-west-1c) for parameter availabilityZone is invalid.
Subnets can currently only be created in the following availability zones:
us-west-1b, us-west-1a.
Is this a transient failure or are there just only two VPC-enabled AZs in that region? If the latter, is there a list somewhere with how many AZs in each region are VPC-enabled?
Each AWS account has own set of the AZ. Get list of the available AZ you can help with AWS cli tools:
aws ec2 describe-availability-zones
See details here: http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-availability-zones.html