Windowsにログイン@EC2

表題を行う必要があり、初めてEC2にWindowsのインスタンスを起動した。

■ 環境

  • Windows 2016
  • AWS EC2
  • Microsoft Remote Desktop
  • macOS High Sierra

■ EC2

Windows Server 2016“のAMIから起動し、RDPを許可したSecurityGroupも作成し設定してある。インスタンスが起動した後、さてどうやれば良いのか?と悩んだが、ManagementConsoleのインスタンス一覧でWindowsのインスタンスを選択した状態の時に、上部メニューで”接続“が有効になることに初めて気が付いた。

接続“を押すと下記が表示される。

リモートデスクトップファイルのダウンロード“から”.rdp“ファイルをダウンロードした。”Microsoft Remote Desktop“アプリがインストールされていればダブルクリックで画面が表示されるはずである。

ユーザ名は既に入力されている”Administrator“まま。これはManagementConsoleでも表示されていた内容である。パスワードはManagementConsoleで”パスワードの取得“から得ることができる。キーペアのファイルを選択し”パスワードの複合“を押すとパスワードが得られる。

これでログインが可能となった。ただし…コピペができなかったのとキーボードがUS配列であったので長いパスワードを入力するのに手間取った。。

以上。

redash 3.0.0 upgrade

表題の通り。公式のAMIで起動しているredashで下記のような表示がされていたのでupgradeしてみた。たぶん使い始めた時にはすでに表示されていたはずである…。

■ 環境

  • redash 2.0.0 → 3.0.0
  • Ubuntu 16.04
  • AWS

■ redash upgrade

New Redash version available“のリンクからアクセスし、upgradeの方法を確認してみる。

Re:dash Releases
https://version.redash.io/

最新版である”3.0.0“の”Upgrade Instructions“から下記にアクセスした。

How to Upgrade | Redash
https://redash.io/help/open-source/admin-guide/how-to-upgrade

この通りコマンドを実行したがエラーとなった。

$ sudo /opt/redash/current/bin/upgrade
Starting Redash upgrade:
Found version: 3.0.0
Current version: 2.0.0+b2990
* Before doing an upgrade, please make sure you have a backup.
* If you have any issues, please refer to the troubleshooting section in the upgrade guide:
https://redash.io/help-onpremise/maintenance/how-to-upgrade-redash.html
* If the upgrade guide doesn't help, you can ask for help on the forum (https://discuss.redash.io).

Full CHANGELOG for this release: https://github.com/getredash/redash/blob/master/CHANGELOG.md
Continue with upgrade? (y/n): y
Downloading release tarball...
Unpacking to: redash.3.0.0.b3134...
Changing ownership to redash...
Linking .env file...
Installing new Python packages (if needed)...
Running migrations (if needed)...
Failed running: sudo -u redash bin/run ./manage.py db upgrade
Exit status: 1
Output:
Traceback (most recent call last):
  File "/opt/redash/redash.3.0.0.b3134/manage.py", line 6, in 
    from redash.cli import manager
  File "/opt/redash/redash.3.0.0.b3134/redash/__init__.py", line 70, in 
    import_query_runners(settings.QUERY_RUNNERS)
  File "/opt/redash/redash.3.0.0.b3134/redash/query_runner/__init__.py", line 175, in import_query_runners
    __import__(runner_import)
  File "/opt/redash/redash.3.0.0.b3134/redash/query_runner/big_query.py", line 18, in 
    import apiclient.errors
  File "/usr/local/lib/python2.7/dist-packages/apiclient/__init__.py", line 19, in 
    from googleapiclient import discovery
  File "/usr/local/lib/python2.7/dist-packages/googleapiclient/discovery.py", line 71, in 
    from oauth2client.client import GoogleCredentials
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 47, in 
    from oauth2client import crypt
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/crypt.py", line 45, in 
    from oauth2client import _openssl_crypt
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/_openssl_crypt.py", line 16, in 
    from OpenSSL import crypto
  File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in 
    from OpenSSL import rand, crypto, SSL
  File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in 
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

$

前述のURLの”Troubleshooting“に記載があったので”pyOpenSSL“のversionを確認すると、”3.0.0“では”16.2.0“が必要なようである。現状を確認。

$ pip list --format=legacy | grep pyOpenSSL
pyOpenSSL (0.14)
$

まずは”pyOpenSSL“から”upgrade“する必要があるようだ。

$ sudo pip install --upgrade pyOpenSSL

再度versionを確認すると下記のようになった。

$ pip list --format=legacy | grep pyOpenSSL
pyOpenSSL (17.5.0)
$

随分と上がったがまぁ良いだろう。これで再度”upgrade“を実行する。

$ sudo /opt/redash/current/bin/upgrade
Starting Redash upgrade:
Found version: 3.0.0
Current version: 2.0.0+b2990
* Before doing an upgrade, please make sure you have a backup.
* If you have any issues, please refer to the troubleshooting section in the upgrade guide:
https://redash.io/help-onpremise/maintenance/how-to-upgrade-redash.html
* If the upgrade guide doesn't help, you can ask for help on the forum (https://discuss.redash.io).

Full CHANGELOG for this release: https://github.com/getredash/redash/blob/master/CHANGELOG.md
Continue with upgrade? (y/n): y
Downloading release tarball...
Unpacking to: redash.3.0.0.b3134...
Changing ownership to redash...
Linking .env file...
Installing new Python packages (if needed)...
Running migrations (if needed)...
Linking to current version...
Restarting...
Done! Enjoy.
$

画面上でもフッターのversionが”3.0.0“になったのを確認することができた。

以上。

■ 関連

DataSource Athena

旧世代インスタンスタイプの料金

AWSにおいて表題の件について。

■ 環境

  • AWS EC2

■ 料金

料金がいくらであったかと思って下記URLを訪れた。

オンデマンドインスタンスの料金 – Amazon EC2 (仮想サーバ) | AWS
https://aws.amazon.com/jp/ec2/pricing/on-demand/

しかし現在使用しているインスタンスタイプは既に旧世代となってしまっていた為、このページではわからなかった。以前はある程度旧世代の料金も記載されていた気がするのだが…。探していたら『旧世代のインスタンスページ』へのリンクがあった。

旧世代のインスタンス – Amazon EC2 | AWS
https://aws.amazon.com/jp/ec2/previous-generation/

ここに記載されていた。

以上。

WordPressのSSL化で無限ループ

表題の通り。ここではないとあるWordPressのサイトをSSL化した時にハマった。

■ 環境

  • WordPress 4.9.2
  • Amazon Linux
  • EC2
  • ELB

■ WordPress

設定 > 一般』にある下記2つの項目をSSLに設定した。ちなみにSSLはELBで終端とし、EC2へは”http“でアクセスしたい。

  • WordPressアドレス
  • サイトアドレス

どちらも、もともとある設定の”http“を”https“に変更した。”サイトアドレス“の変更時点では問題がなかったのだが、”WordPressアドレス“を”https“に変更したところ無限ループとなってしまった。

原因は、WordPressのPHPでは”https“でアクセスが来るはずと認識しているのに、実際にはELBで終端されているので”http“でアクセスが来てしまっているため、再度”https“にリダイレクトされている…という感じがする。

というわけで下記を”wp-config.php“に入れることで対応が可能であった。

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS'] = 'on';

以上。

ElasticIP Tag

AWAにおいてElasticIPにタグを付けられるようになったようだ。

■ 環境

  • AWS

■ Management Console

ManagementConsoleで見ると下記のようになっていた。

以前はそっけない一覧であったがいろいろと表記が増えた。

  • Name
  • Elastic IP
  • アロケーションID
  • インスタンス
  • プライベートIPアドレス
  • スコープ
  • 関連ID
  • ネットワークインターフェイスID
  • ネットワークインターフェイス所有者ID

以前はインスタンス等しか判別しやすいものがなく、リンクを押してインスタンス一覧の画面に遷移してようやくどのインスタンスに付けられているElasticIPであるかがわかっていたと記憶している。ElasticIPだけでなく、プライベートIPアドレスも表記されるだけでもかなり見やすくなったし判別しやすくなった。さらにタグを付けられることでIPが自動で割り振られているやつでも便利になった。

以上。