Monthly Archives: March 2015

AWS CLIでiam-instance-profileを指定するとUnknown options

  AWS CLIでEC2インスタンスを起動する際、紐付けするIAMロールをオプションで指定したい。   CLIのドキュメントでは、IAM Instance Profileの指定方法は –iam-instance-profile Arn=value,Name=value とある。 しかし、実際に指定するとNameの方がUnknown optionsとなってコマンドが失敗する。   Unknownと言われてしまったら仕方がないので、arn(IAMの画面の”Instance Profile ARN(s)”)だけ指定したら通った。 aws ec2 run-instances –cli-input-json file://hogehoge.json –iam-instance-profile Arn=arn:aws:iam::0000000000:instance-profile/UpdateS3   AWS CLIのドキュメント、ちょくちょく罠が仕掛けられている。日々是修行也。

Windows環境のAWS CLIでec2 create-tagsができない

  Windows(PowerShell)環境でAWS CLIを使い、EC2インスタンス起動後にタグを付与したい。 バージョンはaws-cli/1.7.7 Python/2.7.9 Windows/7。 普通に、PowerShellのコンソールからcreate-tags実行してるのに、クライアントエラーになる。 なぜタグ付けができんのだ。 PS C:\AWS> aws ec2 create-tags –resources i-xxxxxxxx –tags Key=Name,Value=test A client error (InternalError) occurred when calling the CreateTags operation: An internal error has occurred Linux上ではうまくいくのになぜ・・と思いリファレンスを見直すと、 If you are using Windows PowerShell, break out the characters with a backslash (\), surround them with double quotes (“), and then surround the entire key and value structure with single quotes (‘): Command: aws ec2 create-tags –resources i-1a2b3c4d –tags ‘Key=\”[Group]\”,Value=test’ create-tags — AWS CLI 1.7.15 documentation とある。 Windows(PowerShell)の環境では、–tagsの値をシングルクオートで囲む必要があったのであった・・。 PS C:\AWS> aws ec2 create-tags –resources i-xxxxxxxx –tags ‘Key=Name,Value=test’ できた。 罠だわ~。

Amazon Linuxにuser data一発でnginx+HHVMをインストール

  Amazon Linux上に、nginx+HHVM環境をつくりたい。 ググると、以下のサイトがヒットし、一目くじけそうになる。 Building and installing HHVM on Amazon Linux 2014.03 シンドい・・。   しかし、もう少しググると、思ったより簡単にできそう。 Amazon Linux これなら、EC2のインスタンス起動時にUser dataにシェルを渡せば、一発でインストールできそう。   Management Consoleにて、「Amazon Linux AMI 2014.09.2 (HVM) – ami-18869819」を利用し、t2.microのインスタンスを起動する。 途中、「Step 3: Configure Instance Details」画面のAdvanced Detailsで、以下のUser dataをAs textとしてコピペする #!/bin/bash -ex cd /etc/yum.repos.d wget http://www.hop5.in/yum/el6/hop5.repo echo ‘priority=9’ >> hop5.repo echo ‘includepkgs=glog,tbb’ >> hop5.repo wget http://yum.sexydev.com/sexydev-amazon.repo yum -y install nginx php php-mbstring hhvm cd /var/www/html touch index.php echo ‘<?php phpinfo(); ?>’ >> index.php インスタンス起動後、hhvmがインストールできていることを確認。 [ec2-user@ip-192-168-XXX-XXX ~]$ hhvm –version HipHop VM 3.3.6-dev (rel) Compiler: 1426768334_998390448 Repo schema: 999173952_1426768334 Extension API: 20140829 若干コンフィグを修正。 cd /etc/nginx sudo vi nginx.conf 修正点は3箇所。 index定義にindex.phpを追記。 index index.php index.html index.htm; serverセクション内のrootパスを変更。 root /var/www/html; FastCGIのlocation設定をアンコメントした上で、rootとfastcgi_paramの記述を変更。 # pass the PHP scripts to FastCGI server […]