Kunal
Kunal

Reputation: 322

Assign pre-determined list of ips for ec2 instances at launch

Is it possible to assign pre-determined list of ips for ec2 instances while launching? If yes then how could we achieve that?

Upvotes: 0

Views: 129

Answers (2)

Khalid T.
Khalid T.

Reputation: 10547

In EC2 VPC, you can specify the primary IPv4 address during instance launch, but you'll have to launch one instance at a time. You cannot use this option if you're launching more than one instance in the request.

Using CLI

--private-ip-address (string)

[EC2-VPC] The primary IPv4 address. You must specify a value from the IPv4 address range of the subnet. Only one private IP address can be designated as primary. You can't specify this option if you've specified the option to designate a private IP address as the primary IP address in a network interface specification. You cannot specify this option if you're launching more than one instance in the request.

See run-instances.

For example:

aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro --key-name MyKeyPair --security-group-ids sg-903004f8 --subnet-id subnet-6e7f829e --private-ip-address 10.0.1.112

Upvotes: 0

E.J. Brennan
E.J. Brennan

Reputation: 46839

You can allocate EIP - Elastic IP's, and after an instance comes up, assign that EIP to whichever instance you want.

This will work on a small-scale only though, as by default you are only allowed 5 EIP's per region, per account.

If you need more EIPs, you may be able to request it - but if you need a lot more, they may want to help you figure out why you think you need so many, and offer a better option if possible.

You'd need to provide more details for a more specific answer.

Upvotes: 2

Related Questions