Amazon EC2 APIで、us-east以外のregionを管理


 


Amazon EC2でus-west(N. California)にインスタンスを立てたのだが、インスタンス上でec2-describe-instancesしても、何も表示されない。

どうやら、Amazon EC2 API Toolsのデフォルトregionは、us-eastになっているようだ。

http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?setting-up-your-tools.html


By default, the Amazon EC2 tools use the Eastern United States region (us-east-1) with the us-east-1.ec2.amazonaws.com service endpoint URL. This section describes how to specify a different region by changing the service endpoint URL.

regionの切り替えは、環境変数で行う。EC2_URLに、管理を行いたいregionのURLを設定する。

以下は、us-west、Linux環境の例。Windowsなら、当然ながらsetにすること。


export EC2_URL=https://ec2.us-west-1.amazonaws.com

URLのFQDN部分は、ec2-describe-regionsで調べられる模様。


[root@hogehoge ~]# ec2-describe-regions
REGION eu-west-1 ec2.eu-west-1.amazonaws.com
REGION us-east-1 ec2.us-east-1.amazonaws.com
REGION us-west-1 ec2.us-west-1.amazonaws.com

 

関連記事