- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
Hello,
When we choose a subnet where to place our EC2 instance, by default, AWS will provide us with a random AZ.
However, when we now create custom subnets that support (IPv6 or IPv4), we have to place these subnets in an AZ as well. If you have now created these subnets in the default VPC, AWS will automatically only choose the default (so the one that AWS created), as it states when we create an EC2 instance.
If we create our own VPC, we will define the subnet where we place the EC2 instance. It doesn't matter if we have IPv4 or IPv6; AWS will always choose the default subnet. However, a possible solution is that we can add IPv6 CIDR to these default subnets.
**There is no direct API call to the problem ** ; however, using the CLI, we can write a command to launch the EC2 instance; when launching the instance, we also have to specify the subnet-id, which can be randomly generated.
aws ec2 run-instances
--image-id ami-1234567890abcdef0
--instance-type t2.micro
--subnet-id subnet-01234567abcdef01
Of course, this does not only have to be written in the CLI. A very easy way of doing this is by defining a CDK (Cloud Development Kit) program. Some basic programming language is required; however, within some lines of code, we can easily accomplish that.
Contenuto pertinente
- AWS UFFICIALEAggiornata 3 anni fa
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 2 anni fa
I was under the impression that EC2 actually did more than just randomly choose one of the default subnets. I thought it actually did a bit of load balancing to choose which subnet/AZ might better be able to handle the request.
I'm not sure where I got that idea.
If I made that up in my head then yeah, we can just randomly pick them as well.