One of the great features of Amazon EC2 is the possibility to dynamically query and use instance specific metadata, or even custom data. This can be useful for various reasons, and the greatest advantage I’ve personally seen into this, is the possibility to allow the instance to have some information on how to configure itself when first booting (using chef or puppet, or some other configuration management tool).
The Amazon documentation explains how to get this information, basically just by using simple http get requests on the ip: 169.254.169.254, like for ex (for the metadata index):
or for the custom data:
Eucalyptus supports this great feature (starting with v1.4), but we obviously need to target a different ip to retrieve this information (as the amazon ip has nothing to do with our internal cloud ;) ). We need to use the cloud controller IP for the request and the port it is bound (by default 8773 if you have not changed it). This will look like this (you need to run it from inside the actual instance):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
For the user data we can start the eucalyptus instance with:
and later we can then retrieve that information from inside the instance using:
While the documentation for Eucalyptus is getting better with every new version there are still missing parts like this one, and hopefully people looking for this information will find this article useful.