EB CLIのインストール手順(Windows)

AWS

AWS Elastic Beanstalk をコマンドで操作する EB CLI のインストール手順です。
公式ドキュメント(EB CLI のインストール)の推奨通りWindows 10に EB CLI セットアップスクリプト でインストールしました。

まず、GitHubからセットアップスクリプトを取得します。

> git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
Cloning into 'aws-elastic-beanstalk-cli-setup'...
remote: Enumerating objects: 295, done.
Receiving objects:  62% (183/295)sed 0 (delta 0), pack-reused 295
Receiving objects: 100% (295/295), 508.25 KiB | 1.06 MiB/s, done.
Resolving deltas: 100% (163/163), done.

Windows PowerShell でセットアップスクリプトを実行するとセキュリティエラーになったので

> .\aws-elastic-beanstalk-cli-setup\scripts\bundled_installer
.\aws-elastic-beanstalk-cli-setup\scripts\bundled_installer : このシステムではスクリプトの実行が無効になっているため、ファイル C:\temp\aws-elastic-beanstalk-cli-setup\scripts\bundled_installer.ps1 を読み込むことができません。詳細については、「about_Execution_Policies」(https://go.microsoft.com/fwlink/?LinkID=135170) を参照してください。
発生場所 行:1 文字:1
+ .\aws-elastic-beanstalk-cli-setup\scripts\bundled_installer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : セキュリティ エラー: (: ) []、PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

実行ポリシーの設定を試みますが、これもエラーになりました。

> Set-ExecutionPolicy RemoteSigned

実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): y
Set-ExecutionPolicy : レジストリ キー 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' へのアクセスが拒否されました。 既定 (LocalMachine) のスコープの実行ポリシーを変更するには、[管理者として実行] オプションを使用して Windows PowerShell を起動してください。現在のユーザーの実行ポリシーを変更するには、"Set-ExecutionPolicy -Scope CurrentUser" を実行してください。
発生場所 行:1 文字:1
+ Set-ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

PowerShellを管理者モードで開くと実行ポリシーを設定するとことができました。

> Set-ExecutionPolicy RemoteSigned

実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): y

再度セットアップスクリプトを実行してみましたが、次は「virtualenvというモジュールがない」とエラーになってしまいました。

> .\aws-elastic-beanstalk-cli-setup\scripts\bundled_installer

******************************************
1. Creating exclusive virtualenv for EBCLI
******************************************
Traceback (most recent call last):
  File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\temp\aws-elastic-beanstalk-cli-setup\scripts\virtualenv\bin\virtualenv.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'virtualenv'
Exiting due to failure

Troubleshootingの手順に沿ってvirtualenvをインストールします。

> pip uninstall -y virtualenv

> pip install virtualenv

> python .\aws-elastic-beanstalk-cli-setup\scripts\ebcli_installer.py

再度セットアップスクリプトを実行するとインストールが成功しました。

> .\aws-elastic-beanstalk-cli-setup\scripts\bundled_installer

***************
5. Finishing up
***************
Success!
> eb --version
EB CLI 3.20.1 (Python 3.7.3)

コメント

タイトルとURLをコピーしました