AWS EC2インスタンス Windows Server2019を作成してMacから接続
- 2019.11.06
- AWS

はじめに
これまで Amazon Linux2 の EC2 インスタンスを何度も作ってきましたが、Windows系のEC2インスタンスは作ったことがなかったです。ここでは、Windows Server2019のEC2インスタンスを作成し、Macからリモートデスクトップ接続をしてみたいと思います。
セキュリティグループの作成
VPCとサブネットは今までのを使いまわしますが、セキュリティグループだけWindowsServer用のものを作っておきます。RDP用にtcp 3389 ポートを開ける必要があります。
$ aws ec2 create-security-group --group-name winsecgroup --description "Windows Security Group" --vpc-id $vpc_id
{
"GroupId": "sg-01753d7e86961fc8b"
}
$ aws ec2 authorize-security-group-ingress --group-id sg-01753d7e86961fc8b --protocol tcp --port 3389 --cidr 0.0.0.0/0
EC2インスタンスの作成
まずは次のようなJSONファイルを作成しておきます。
{
"ImageId": "ami-0e48df3801c3e668e",
"InstanceType": "t2.micro",
"KeyName": "myawskey-tokyo",
"MaxCount": 1,
"SecurityGroupIds": [
"sg-01753d7e86961fc8b"
],
"SubnetId": "subnet-0b99e52d17314979d"
}
次のコマンドでEC2インスタンスを作成します。
$ aws ec2 run-instances --cli-input-json file://ec2-windows.json
これでEC2インスタンスが作成できます。
Microsoft Remote Desktopで接続
現在のMicrosoft Remote Desktopのバージョンは10.3.4です。このアプリケーションを使ってEC2インスタンスに接続してみたいと思います。PC nameのところにPublic DNS name を入力しておきます。

次のコマンドで Administrator のパスワードを取得します。
$ aws ec2 get-password-data --instance-id $ins_id --priv-launch-key $key
{
"InstanceId": "i-08b31319275529c35",
"PasswordData": "hogepassword",
"Timestamp": "2019-11-06T06:54:14.000Z"
}


接続できました。
-
前の記事
AWS VM Import を試してみる 2019.11.05
-
次の記事
AWS EC2インスタンスのRAID化(Windows Server編) 2019.11.07