4

Is it possible to do the following with AWS EC2? And if so what is the AWS CLI command for it?

  1. Launch an instance and bind an Elastic IP at the same time
  2. Change the hostname of an instance that is created with from the AWS CLI

http://docs.aws.amazon.com/cli/latest/index.html

Thanks


@ EEAA - I did try to associate and EIP after creation but other than doing a sloppy polling or sleep solution you run the risk of the instance being in the pending state, which makes it unable to bind the address to the instance.

3

Launch an instance and bind an Elastic IP at the same time

No, not in your run-instances call. You'll need to issue a second command using the associate-address option, as documented here.

Change the hostname of an instance that is created with from the AWS CLI

No, setting hostname needs to be part of your post-creation instance configuration.

| improve this answer | |
  • 1
    I've seen some confusion over the need to bind an elastic IP. I believe in the original VPC product a node would not get a public IP unless an Elastic IP was bound. In the current product you can get a public IP assigned as part of instance creation (ether explicitly or by default based on the subnet configuration), but it is randomly assigned as opposed to the statically assigned Elastic IP. – Jason Martin Mar 30 '16 at 16:19
  • Yes, that's correct. Seems more of a comment on the question, though, than on my answer. Or not? – EEAA Mar 30 '16 at 16:56
  • @ EEAA - I did try to associate and EIP after creation but other than doing a sloppy polling or sleep solution you run the risk of the instance being in the pending state, which makes it unable to bind the address to the instance. – Arnab C. Mar 30 '16 at 17:18
  • @EEAA Both really -- you said 'no' which is correct but if the poster is operating under the much older product understanding then the answer can be considered 'yes'. – Jason Martin Mar 31 '16 at 14:55
  • 1
    @Jib what about having the node do the EIP itself as part of bootup? – Jason Martin Mar 31 '16 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.