0

So I'm using knife ec2 plugin to create a server, inside a VPC, and then provision it with chef-solo.

Here is my basic command:

    knife ec2 server create -S private-key -I ami-1234 --flavor=m1.medium --subnet xyz

The server is spun up properly, and has the proper VPC IP address. My problem is, I also need a public IP address. When I spin up an instance through the ec2 web console, it simply has an option for this Automatically assign a public IP address to your instances

I simply am unable to figure out how to do this via the knife command.

2

Here is one solution I have used, although note that it requires a manual step and knowledge of your free elastic IP pool:

  • Create one or more elastic IPs on the EC2 webconsole
  • On the end of your knife ec2 create server command add --associate-eip <free elastic ip address>
| improve this answer | |
  • Thanks for this correct answer. Additionally for those that might end up on this page, if you don't want to use an 'EIP' but just an auto-generated public IP you can include "--associate-public-ip" Then if you want to connect via the private IP and not the public (usually for security related concerns) use "--server-connect-attribute private_ip_address" – comjf Jun 12 '17 at 17:06

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.