I want to create a EC2 instance using knife with an elastic ip assigned to it. Knife has the option --associate-eip but when I use this option it fails with error "ERROR: Elastic IP requested is not available." eventhough the EIP in AWS console shows the IP is available.

The command I executed

knife ec2 server create -S testKey -I ami-e7b8c0d7 --security-group-id test_sg -N test-eip -f m3.medium --region us-west-2 -i testKey.pem --associate-eip

ERROR: Elastic IP requested is not available.

Did I miss any obvious steps? Where does knife look for the elastic ip list? Is there a place to inform abt the elastic ip list to knife?


After adding the --subnet attribute with the default subnetid of that region and adding --server-connect-attribute public_ip_address, its possible to create instances with eip assigned.

knife ec2 server create -N test-eip -I ami-e7b8c0d7 --security-group-id sg-685a00d -f m3.medium --region us-west-2 --ssh-user ubuntu -S testKey -i key.pem --associate-eip --subnet <default subnetid for that region> --server-connect-attribute public_ip_address

To find the default subnetid of the region, launch the instance and in the "Configure Instance Details" take subnet id that is displayed.

| improve this answer | |

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.