■AWSで英語版Windowsインスタンスを使ってみる。
今回はものすごく普通にWebから、AWSコンソールでポチポチしてRemminaでRDP接続してみただけ。
RDPで外につなげる想定の無い環境なので、それでも内から外へのFirewall開けたり色々結構面倒だった。
結果をawscliで眺めていくだけの簡単なお仕事。
■AWSCLIコマンドをしばらく使っていなかったため、バージョンが古いと思ったらstretchとしては最新。
jqとawscliを導入してみる。
http://labunix.hateblo.jp/entry/20180917/1537117696
$ apt-cache show awscli | grep Filename
Filename: pool/main/a/awscli/awscli_1.11.13-1_all.deb
$ aws --version
aws-cli/1.11.13 Python/3.5.3 Linux/4.9.0-8-amd64 botocore/1.4.70
■公式サイトの情報をもとに、ホームディレクトリ以下にアップグレード(インストール)する。
「export PATH~」はログオフ後に破棄されるので、.bashrcなどに書いておく。
AWS Command Line Interface をインストールする
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-chap-install.html
$ python --version
Python 2.7.13
$ pip install awscli --upgrade --user
$ ~/.local/bin/aws --version
aws-cli/1.16.106 Python/2.7.13 Linux/4.9.0-8-amd64 botocore/1.12.96
$ find . -type f -name "aws"
./.local/bin/aws
$ ~/.local/bin/aws --version
aws-cli/1.16.106 Python/2.7.13 Linux/4.9.0-8-amd64 botocore/1.12.96
$ ~/.local/bin/aws configure
AWS Access Key ID [****************XXXX]:
AWS Secret Access Key [****************XXXX]:
Default region name [xx-xxxxx-n]:
Default output format [json]:
$ export PATH=~/.local/bin:$PATH
$ aws --version
aws-cli/1.16.106 Python/2.7.13 Linux/4.9.0-8-amd64 botocore/1.12.96
$ tail -1 .bashrc
export PATH=/home/labunix/.local/bin:/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
■せっかくなので、以下を少し改良して。。。
awscliでAWSリージョンとAZの一覧を取得する
http://labunix.hateblo.jp/entry/20180918/1537269823
■リージョン、AZの選択肢の確認
リージョン名、AZ数とAZ名のカンマ区切りの一覧
$ aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text | sort -k 1 | \
awk '{print "echo -n \042"$1 \
",\042;aws ec2 describe-availability-zones --query \047AvailabilityZones[].{Name:ZoneName}\047 --region "$1 \
" --output text | awk \047{a=a\042,\042$0}END{print NR,a}\047"}' | sh
ap-northeast-1,3 ,ap-northeast-1a,ap-northeast-1c,ap-northeast-1d
ap-northeast-2,2 ,ap-northeast-2a,ap-northeast-2c
ap-south-1,2 ,ap-south-1a,ap-south-1b
ap-southeast-1,3 ,ap-southeast-1a,ap-southeast-1b,ap-southeast-1c
ap-southeast-2,3 ,ap-southeast-2a,ap-southeast-2b,ap-southeast-2c
ca-central-1,2 ,ca-central-1a,ca-central-1b
eu-central-1,3 ,eu-central-1a,eu-central-1b,eu-central-1c
eu-north-1,3 ,eu-north-1a,eu-north-1b,eu-north-1c
eu-west-1,3 ,eu-west-1a,eu-west-1b,eu-west-1c
eu-west-2,3 ,eu-west-2a,eu-west-2b,eu-west-2c
eu-west-3,3 ,eu-west-3a,eu-west-3b,eu-west-3c
sa-east-1,2 ,sa-east-1a,sa-east-1c
us-east-1,6 ,us-east-1a,us-east-1b,us-east-1c,us-east-1d,us-east-1e,us-east-1f
us-east-2,3 ,us-east-2a,us-east-2b,us-east-2c
us-west-1,2 ,us-west-1a,us-west-1b
us-west-2,3 ,us-west-2a,us-west-2b,us-west-2c
■AZの地理を確認する。
$ w3m -dump "https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/using-regions-availability-zones.html" | \
awk '/[a-z]?-[a-z]*[1-9]/&&!/に|は|が|を|に|と/' | sort -k 1
ap-northeast-1 アジアパシフィック (東京)
ap-northeast-2 アジアパシフィック (ソウル)
ap-northeast-3 アジアパシフィック (大阪: ローカル)
ap-south-1 アジアパシフィック (ムンバイ)
ap-southeast-1 アジアパシフィック (シンガポール)
ap-southeast-2 アジアパシフィック (シドニー)
ca-central-1 カナダ (中部)
eu-central-1 欧州 (フランクフルト)
eu-north-1 欧州 (ストックホルム)
eu-west-1 欧州 (アイルランド)
eu-west-2 欧州 (ロンドン)
eu-west-3 EU (パリ)
sa-east-1 南米 (サンパウロ)
us-east-1 米国東部(バージニア北部)
us-east-2 米国東部 (オハイオ)
us-west-1 米国西部 (北カリフォルニア)
us-west-2 米国西部 (オレゴン)
■AZ毎のサブネットを確認
$ aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text | sort -k 1 | \
awk '{print "aws ec2 describe-subnets --region "$1 \
" --query \047Subnets[].{SubnetId:SubnetId,CidrBlock:CidrBlock,AvailabilityZone:AvailabilityZone }\047 " \
" --output text"}' | sh
ap-northeast-1a 172.31.32.0/20 subnet-bf9488f6
ap-northeast-1c 172.31.0.0/20 subnet-78bff123
ap-northeast-1d 172.31.16.0/20 subnet-d96e89f2
ap-northeast-2a 172.31.0.0/20 subnet-fab6a392
ap-northeast-2c 172.31.16.0/20 subnet-a73f47eb
ap-south-1a 172.31.16.0/20 subnet-56aaea3e
ap-south-1b 172.31.0.0/20 subnet-47bc0d0b
ap-southeast-1b 172.31.16.0/20 subnet-defbf3b9
ap-southeast-1c 172.31.0.0/20 subnet-3ee12667
ap-southeast-1a 172.31.32.0/20 subnet-b94c74f0
ap-southeast-2c 172.31.16.0/20 subnet-c26dc19a
ap-southeast-2b 172.31.32.0/20 subnet-818da2c8
ap-southeast-2a 172.31.0.0/20 subnet-ea714c8d
ca-central-1a 172.31.16.0/20 subnet-0ffa7367
ca-central-1b 172.31.0.0/20 subnet-ae5d87d4
eu-central-1b 172.31.32.0/20 subnet-b79fdcca
eu-central-1c 172.31.0.0/20 subnet-c76c3a8a
eu-central-1a 172.31.16.0/20 subnet-72071319
eu-north-1b 172.31.32.0/20 subnet-940210ec
eu-north-1c 172.31.0.0/20 subnet-cf94a985
eu-north-1a 172.31.16.0/20 subnet-1392617a
eu-west-1c 172.31.0.0/20 subnet-c39e0ea5
eu-west-1b 172.31.32.0/20 subnet-8c06d4d6
eu-west-1a 172.31.16.0/20 subnet-aaf797e2
eu-west-2c 172.31.0.0/20 subnet-098f1660
eu-west-2a 172.31.16.0/20 subnet-09c96c73
eu-west-2b 172.31.32.0/20 subnet-5935dd15
eu-west-3b 172.31.16.0/20 subnet-0aa73671
eu-west-3c 172.31.32.0/20 subnet-45fa2008
eu-west-3a 172.31.0.0/20 subnet-ac631dc5
sa-east-1a 172.31.0.0/20 subnet-c7e114a1
sa-east-1c 172.31.16.0/20 subnet-c15aaa9a
us-east-1a 172.31.16.0/20 subnet-d57f299f
us-east-1f 172.31.64.0/20 subnet-a47109ab
us-east-1b 172.31.32.0/20 subnet-999b18c5
us-east-1c 172.31.0.0/20 subnet-9bf274fc
us-east-1e 172.31.48.0/20 subnet-da05cfe4
us-east-1d 172.31.80.0/20 subnet-07870a29
us-east-2a 172.31.0.0/20 subnet-fcaf8b94
us-east-2c 172.31.32.0/20 subnet-d9f13495
us-east-2b 172.31.16.0/20 subnet-8e3caef4
us-west-1b 172.31.16.0/20 subnet-73d8c914
us-west-1a 172.31.0.0/20 subnet-ea331eb1
us-west-2c 172.31.0.0/20 subnet-a41538fe
us-west-2b 172.31.16.0/20 subnet-2725775e
us-west-2a 172.31.32.0/20 subnet-f388f4b8
■スポット価格と比較出来るように価格の安い順に一覧する、全AZ毎にフィルタ。
$ aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text | sort -k 1 | \
awk '{print "aws ec2 describe-availability-zones --query \047AvailabilityZones[].{Name:ZoneName}\047 --region "$1 \
" --output text"}' | sh | \
awk '{print " aws ec2 describe-spot-price-history" \
" --availability-zone "$1 \
" --start-time $(date -d \0471 days ago\047 -u \047+%Y-%m-%dT%H:%M:%S.000Z\047)" \
" --product-description \042Linux/UNIX\042" \
" --instance-types t3.small t3.micro t3.nano" \
" --query \047SpotPriceHistory[].{InstanceType:InstanceType," \
"ProductDescription:ProductDescription,AvailabilityZone:AvailabilityZone,SpotPrice:SpotPrice}\047" \
" --output text"}' | sh 2>/dev/null
us-west-1a t3.nano Linux/UNIX 0.001900
us-west-1a t3.nano Linux/UNIX 0.001900
us-west-1a t3.small Linux/UNIX 0.007700
us-west-1a t3.small Linux/UNIX 0.007700
us-west-1a t3.micro Linux/UNIX 0.003700
us-west-1a t3.small Linux/UNIX 0.007800
us-west-1a t3.micro Linux/UNIX 0.003700
us-west-1a t3.nano Linux/UNIX 0.001900
us-west-1a t3.small Linux/UNIX 0.007900
us-west-1b t3.nano Linux/UNIX 0.001900
us-west-1b t3.nano Linux/UNIX 0.001900
us-west-1b t3.small Linux/UNIX 0.007500
us-west-1b t3.micro Linux/UNIX 0.003700
us-west-1b t3.micro Linux/UNIX 0.003700
us-west-1b t3.small Linux/UNIX 0.007500
us-west-1b t3.nano Linux/UNIX 0.001900
■nano、microは過去3日および2018/09/18で同じため、価格変動はほぼない様子。
t3.smallが多少増減している様子。
$ aws ec2 describe-spot-price-history \
--start-time $(date -d '3 days ago' -u '+%Y-%m-%dT%H:%M:%S.000Z') \
--product-description "Linux/UNIX" \
--instance-types t3.small t3.micro t3.nano \
--query 'SpotPriceHistory[].{InstanceType:InstanceType,ProductDescription:ProductDescription,AvailabilityZone:AvailabilityZone,SpotPrice:SpotPrice}' \
--output text | awk '{a[$0]+=1}END{for(n in a){print a[n],n}}' | sort -k 4
5 us-west-1a t3.nano Linux/UNIX 0.001900
5 us-west-1b t3.nano Linux/UNIX 0.001900
4 us-west-1a t3.micro Linux/UNIX 0.003700
4 us-west-1b t3.micro Linux/UNIX 0.003700
4 us-west-1b t3.small Linux/UNIX 0.007500
2 us-west-1a t3.small Linux/UNIX 0.007700
1 us-west-1a t3.small Linux/UNIX 0.007800
1 us-west-1a t3.small Linux/UNIX 0.007900
1 us-west-1a t3.small Linux/UNIX 0.008000
1 us-west-1a t3.small Linux/UNIX 0.008100
■vpcイメージのAMI検索
「block-device-mapping.volume-type=standard」で絞るとかなりレスポンスが速くなる。
grepで2018年か,2019年に限定している。
$ time aws ec2 describe-images \
--filters "Name=block-device-mapping.volume-type,Values=standard" \
"Name=name,Values=*vpc*" \
--query 'Images[].[Name, ImageId, OwnerId]' --output text | grep 201[89]\.
amzn-ami-vpc-nat-hvm-2017.09.1-testlongids.20180307-x86_64-ebs ami-042f8760634b93f20 137112412989
amzn-ami-vpc-nat-hvm-2018.03.0.20181116-x86_64-ebs ami-097ad469381034fa2 137112412989
amzn-ami-vpc-nat-hvm-2018.03.0.20180811-x86_64-ebs ami-0d4027d2cdbca669d 137112412989
amzn-ami-vpc-nat-hvm-2018.03.0.20180508-x86_64-ebs ami-1a0e107a 137112412989
amzn-ami-vpc-nat-hvm-2017.09.1.20180115-x86_64-ebs ami-394e4c59 137112412989
amzn-ami-vpc-nat-hvm-2017.09.1.20180108-x86_64-ebs ami-4fefef2f 137112412989
amzn-ami-vpc-nat-hvm-2018.03.0.20180622-x86_64-ebs ami-8c8761ef 137112412989
amzn-ami-vpc-nat-hvm-2018.03.0.20180412-x86_64-ebs ami-c1e1f2a1 137112412989
amzn-ami-vpc-nat-hvm-2017.09.1.20180103-x86_64-ebs ami-c59495a5 137112412989
amzn-ami-vpc-nat-hvm-2017.09.1.20180307-x86_64-ebs ami-da5441ba 137112412989
real 0m2.733s
user 0m0.568s
sys 0m0.060s
■microsoftのAMI検索
$ time aws ec2 describe-images --owners="microsoft" --query 'Images[].[Name, ImageId, OwnerId]' --output text
Windows_Server-2008-R2-SP1-English-64Bit-WebMatrix_Development-2012.06.12 ami-99c892dc 461346954234
Windows_Server-2008-R2-SP1-English-64Bit-WebMatrix_Hosting-2012.06.12 ami-9bc892de 461346954234
Windows_Server-2008-R2-SP1-English-64Bit-SQL_2008_R2_SP1_Standard-2012.06.12 ami-9bf1abde 461346954234
Windows_Server-2008-R2-SP1-English-64Bit-Windows_Media_Services_4.1-2012.06.12 ami-a3c892e6 461346954234
real 0m1.228s
user 0m0.568s
sys 0m0.072s
■debian-stretchのAMI検索
$ time aws ec2 describe-images \
--filters "Name=name,Values=debian-stretch*" \
--query 'Images[].[Name, ImageId, OwnerId]' \
--output text | grep 201[89]-
debian-stretch-hvm-x86_64-gp2-2018-08-20-85640 ami-00b2578f8d3753164 379101102735
debian-stretch-hvm-x86_64-gp2-2018-08-14-82175 ami-0636bbe89b7d64bc6 379101102735
debian-stretch-hvm-x86_64-gp2-2018-11-10-63975-572488bb-fc09-4638-8628-e1e1d26436f4-ami-0f4768a55eaaac3d7.4 ami-09136521b9fd9a420 679593333241
debian-stretch-hvm-x86_64-gp2-2019-01-22-59357 ami-0d6c332a2e4be8050 379101102735
debian-stretch-hvm-x86_64-gp2-2018-11-10-63975 ami-0ebddb8af2428fc2e 379101102735
debian-stretch-hvm-x86_64-gp2-2018-10-01-66564 ami-0f0674cb683fcc1f7 379101102735
debian-stretch-hvm-x86_64-gp2-2019-01-14-59254 ami-0fdc435b23998a98b 379101102735
debian-stretch-hvm-x86_64-gp2-2018-07-15-72527 ami-1a9d7f79 379101102735
debian-stretch-hvm-x86_64-gp2-2018-01-06-16218 ami-6d03030d 379101102735
debian-stretch-hvm-x86_64-gp2-2018-03-11-19642 ami-76e3f616 379101102735
debian-stretch-hvm-x86_64-gp2-2018-02-22-67467 ami-8c828aec 379101102735
debian-stretch-hvm-x86_64-gp2-2018-06-13-59294 ami-a126c2c2 379101102735
debian-stretch-hvm-x86_64-gp2-2018-08-07-16934 ami-ad1df2ce 379101102735
debian-stretch-hvm-x86_64-gp2-2018-05-01-84002 ami-c55e41a5 379101102735
debian-stretch-hvm-x86_64-gp2-2018-04-09-292 ami-d6a5b5b6 379101102735
debian-stretch-hvm-x86_64-gp2-2018-05-14-16107 ami-da6178ba 379101102735
real 0m2.196s
user 0m0.604s
sys 0m0.032s
$ time aws ec2 describe-images \
--filters "Name=owner-id,Values=379101102735" \
--query 'Images[].[Name, ImageId]' --output text | grep stretch
debian-stretch-hvm-x86_64-gp2-2018-08-20-85640 ami-00b2578f8d3753164
debian-stretch-hvm-x86_64-gp2-2018-08-14-82175 ami-0636bbe89b7d64bc6
debian-stretch-hvm-x86_64-gp2-2019-01-22-59357 ami-0d6c332a2e4be8050
debian-stretch-hvm-x86_64-gp2-2018-11-10-63975 ami-0ebddb8af2428fc2e
debian-stretch-hvm-x86_64-gp2-2018-10-01-66564 ami-0f0674cb683fcc1f7
debian-stretch-hvm-x86_64-gp2-2019-01-14-59254 ami-0fdc435b23998a98b
debian-stretch-hvm-x86_64-gp2-2018-07-15-72527 ami-1a9d7f79
debian-stretch-amd64-hvm-2016-09-23-08-48-ebs ami-25317f45
debian-stretch-hvm-x86_64-gp2-2017-08-31-64407 ami-560c3836
debian-stretch-hvm-x86_64-gp2-2017-10-08-48016 ami-58eedd38
debian-stretch-hvm-x86_64-gp2-2017-12-17-65723 ami-5d55523d
debian-stretch-hvm-x86_64-gp2-2018-01-06-16218 ami-6d03030d
debian-stretch-hvm-x86_64-gp2-2018-03-11-19642 ami-76e3f616
debian-stretch-hvm-x86_64-gp2-2017-07-22-75922 ami-7df8d11d
debian-stretch-hvm-x86_64-gp2-2018-02-22-67467 ami-8c828aec
debian-stretch-hvm-x86_64-gp2-2018-06-13-59294 ami-a126c2c2
debian-stretch-hvm-x86_64-gp2-2017-12-24-71024 ami-aa1610ca
debian-stretch-hvm-x86_64-gp2-2018-08-07-16934 ami-ad1df2ce
debian-stretch-hvm-x86_64-gp2-2018-05-01-84002 ami-c55e41a5
debian-stretch-hvm-x86_64-gp2-2017-06-21-52542 ami-c8a68ba8
debian-stretch-hvm-x86_64-gp2-2017-04-20-82073 ami-ce3115ae
debian-stretch-hvm-x86_64-gp2-2018-04-09-292 ami-d6a5b5b6
debian-stretch-hvm-x86_64-gp2-2018-05-14-16107 ami-da6178ba
real 0m2.413s
user 0m0.564s
sys 0m0.044s
■まとめると、owner-idのフィルタと、
作成日時のフォーマットをちょっといじってあげればそれなりのリストになる。
$ time aws ec2 describe-images --filters "Name=owner-id,Values=379101102735,461346954234,137112412989" "Name=name,Values=*amzn*,*vpc*,debian-stretch*,*Windows*" --query 'sort_by(Images[].{YMD:CreationDate,Name:Name,ImageId:ImageId,OwnerId:OwnerId},&YMD)|reverse(@)' --output text | awk '(length($1)>20 && $NF ~ /2019-/)||$2 ~ /Windows/{gsub("T|.000Z"," ",$NF);print $0}'
ami-0d6c332a2e4be8050 debian-stretch-hvm-x86_64-gp2-2019-01-22-59357 379101102735 2019-01-22 18:44:28
ami-0fdc435b23998a98b debian-stretch-hvm-x86_64-gp2-2019-01-14-59254 379101102735 2019-01-14 22:10:56
ami-02b54bf0d4dd14e8e amzn2-ami-minimal-hvm-2.0.20190115-x86_64-ebs 137112412989 2019-01-14 19:24:01
ami-0799ad445b5727125 amzn2-ami-hvm-2.0.20190115-x86_64-gp2 137112412989 2019-01-14 19:17:26
ami-04934beceb260ec14 amzn2-ami-hvm-2.0.20190115-x86_64-ebs 137112412989 2019-01-14 19:13:18
ami-0c5a40795c61e282d amzn2-ami-minimal-hvm-2.0.20190110-x86_64-ebs 137112412989 2019-01-08 06:53:59
ami-0a16c82eb0cc3aad8 amzn2-ami-hvm-2.0.20190110-x86_64-gp2 137112412989 2019-01-08 06:47:17
ami-0d480e8664c70e3d6 amzn2-ami-hvm-2.0.20190110-x86_64-ebs 137112412989 2019-01-08 06:44:10
ami-9bf1abde Windows_Server-2008-R2-SP1-English-64Bit-SQL_2008_R2_SP1_Standard-2012.06.12 461346954234 2012-06-15 17:26:19
ami-a3c892e6 Windows_Server-2008-R2-SP1-English-64Bit-Windows_Media_Services_4.1-2012.06.12 461346954234 2012-06-12 22:43:56
ami-9bc892de Windows_Server-2008-R2-SP1-English-64Bit-WebMatrix_Hosting-2012.06.12 461346954234 2012-06-12 22:43:03
ami-99c892dc Windows_Server-2008-R2-SP1-English-64Bit-WebMatrix_Development-2012.06.12 461346954234 2012-06-12 22:42:45
real 0m9.550s
user 0m0.824s
sys 0m0.112s
■10秒程度なら待てそうなので、amazon+microsoftの一覧も。
$ time aws ec2 describe-images --owners amazon \
--filters "Name=name,Values=Windows*201*Japan*" \
--query 'sort_by(Images[].{YMD:CreationDate,Name:Name,ImageId:ImageId,OwnerId:OwnerId},&YMD)|reverse(@)' \
--output text | awk '(length($1)>20 && $NF ~ /2019-/)&&$2 ~ /Windows/{gsub("T|.000Z"," ",$NF);print $0}'
ami-02e00d3f2329727cd Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2019.02.13 801119661308 2019-02-13 19:56:11
ami-0612311692d26d84e Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Web-2019.02.13 801119661308 2019-02-13 14:03:21
ami-0296843d5425acee4 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Enterprise-2019.02.13 801119661308 2019-02-13 12:16:36
ami-092c412eac5ae59a6 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP3_Express-2019.02.13 801119661308 2019-02-13 11:43:45
ami-09987a9982148e5a4 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Web-2019.02.13 801119661308 2019-02-13 10:23:11
ami-0edbc289c26173619 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Standard-2019.02.13 801119661308 2019-02-13 10:23:06
ami-0c39fedb167d029b0 Windows_Server-2012-R2_RTM-Japanese-64Bit-Base-2019.02.13 801119661308 2019-02-13 10:18:15
ami-08cb0992584376830 Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Web-2019.02.13 801119661308 2019-02-13 09:54:55
ami-0bf72651ae3f804ff Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Standard-2019.02.13 801119661308 2019-02-13 09:54:48
ami-0c39cb6e5425ffb06 Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Express-2019.02.13 801119661308 2019-02-13 09:54:42
ami-089f6819226a2a53a Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Enterprise-2019.02.13 801119661308 2019-02-13 09:54:36
ami-084f0892097d8f99d Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Web-2019.02.13 801119661308 2019-02-13 09:54:30
ami-07444cbf26cf7719c Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Standard-2019.02.13 801119661308 2019-02-13 09:54:24
ami-0a139b003a89d61ac Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Express-2019.02.13 801119661308 2019-02-13 09:54:16
ami-0463855b465267c16 Windows_Server-2016-Japanese-Full-Base-2019.02.13 801119661308 2019-02-13 09:54:10
ami-0f7600b6532d9da9a Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Standard-2019.02.13 801119661308 2019-02-13 09:43:17
ami-0c5ae43f1867861d0 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Express-2019.02.13 801119661308 2019-02-13 09:43:10
ami-0d8839b9e7141253c Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Enterprise-2019.02.13 801119661308 2019-02-13 09:43:03
ami-0007bc1c96c926476 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Web-2019.02.13 801119661308 2019-02-13 09:42:56
ami-0d8571a2363dfa8c4 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Standard-2019.02.13 801119661308 2019-02-13 09:42:50
ami-04baae9c2d7438a2d Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Express-2019.02.13 801119661308 2019-02-13 09:42:43
ami-0cc8462207cf00072 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Enterprise-2019.02.13 801119661308 2019-02-13 09:42:36
ami-00c276524f02d87ff Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP3_Standard-2019.02.13 801119661308 2019-02-13 09:42:30
ami-0ede0e523cda70e9b Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Express-2019.02.13 801119661308 2019-02-13 09:42:23
ami-04f3846cda502d9fd Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Web-2019.02.13 801119661308 2019-02-13 09:11:33
ami-077dd9f7fb837755b Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Standard-2019.02.13 801119661308 2019-02-13 09:11:26
ami-0e5f4c4fa21c4807f Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Express-2019.02.13 801119661308 2019-02-13 09:11:20
ami-00169ed356a848f4a Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Web-2019.02.13 801119661308 2019-02-13 09:11:14
ami-06f325b9202c43cca Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2019.02.13 801119661308 2019-02-13 09:11:06
ami-0421c8c3f4d6524d7 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Express-2019.02.13 801119661308 2019-02-13 09:10:55
ami-063ccfda8a84f1514 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Express-2019.02.13 801119661308 2019-02-13 09:10:44
ami-0cac07d4996d2a5f3 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Standard-2019.02.13 801119661308 2019-02-13 08:29:42
ami-0477e8d7c53d5f9eb Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Express-2019.02.13 801119661308 2019-02-13 08:29:36
ami-0048904c2595ed1c3 Windows_Server-2012-RTM-Japanese-64Bit-Base-2019.02.13 801119661308 2019-02-13 08:29:29
ami-0b8dc5273648c8e76 Windows_Server-2019-Japanese-Full-Base-2019.02.13 801119661308 2019-02-13 08:03:23
ami-0cf9e87281397877b Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Standard-2018.12.13 801119661308 2019-02-09 12:00:34
ami-0bfa755bab1d01545 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Web-2018.12.13 801119661308 2019-02-09 11:03:22
ami-05dfde831a3225d39 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Standard-2018.12.13 801119661308 2019-02-09 11:03:15
ami-03b1cdfc88850f471 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Web-2018.12.13 801119661308 2019-02-09 11:02:47
ami-05f772f57fb92289d Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2018.12.13 801119661308 2019-02-09 11:02:39
ami-0f78aad419fd3769e Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Express-2018.12.13 801119661308 2019-02-09 11:02:33
ami-0c1076d6d47ae4b25 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Web-2018.12.13 801119661308 2019-02-09 11:02:25
ami-0b9f206f7c1338430 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Standard-2018.12.13 801119661308 2019-02-09 11:02:20
ami-096fedc62246b7348 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Express-2018.12.13 801119661308 2019-02-09 11:02:12
ami-02cf416421501c3a4 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Express-2018.12.13 801119661308 2019-02-09 11:02:04
ami-0255949db7b205b4f Windows_Server-2012-RTM-Japanese-64Bit-Base-2018.12.13 801119661308 2019-02-09 11:01:58
ami-0fbd9de3f80028a65 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Standard-2018.12.13 801119661308 2019-02-09 10:56:23
ami-036649180e237518d Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Express-2018.12.13 801119661308 2019-02-09 10:56:16
ami-056545290f16f9125 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Enterprise-2018.12.13 801119661308 2019-02-09 10:56:10
ami-09072c4562e1bdcc4 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Standard-2018.12.13 801119661308 2019-02-09 10:55:54
ami-06908b536ac0e262d Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Enterprise-2018.12.13 801119661308 2019-02-09 10:55:37
ami-0e245ee9e1d3af10b Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP3_Standard-2018.12.13 801119661308 2019-02-09 10:55:30
ami-0d644671e6691e73a Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP3_Express-2018.12.13 801119661308 2019-02-09 10:55:24
ami-01cc7d381fb9cebb0 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2018.12.13 801119661308 2019-02-09 10:55:17
ami-0da15102f201f5136 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Express-2018.12.13 801119661308 2019-02-09 10:55:11
ami-05b64959aaf6544e4 Windows_Server-2012-R2_RTM-Japanese-64Bit-Base-2018.12.13 801119661308 2019-02-09 10:55:05
ami-04bbfc54bb05f6eee Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Web-2018.11.29 801119661308 2019-02-09 05:32:34
ami-0576c19f17c9ce726 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2018.11.29 801119661308 2019-02-09 05:32:29
ami-0637a6ab45d44f8a3 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Express-2018.11.29 801119661308 2019-02-09 05:32:23
ami-05a642333b63c7ae9 Windows_Server-2012-R2_RTM-Japanese-64Bit-Base-2018.11.29 801119661308 2019-02-09 04:43:31
ami-01dd02b77710375f5 Windows_Server-2019-Japanese-Full-Base-2019.02.09 801119661308 2019-02-09 04:37:37
ami-057c7be9bbe5b446c Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Express-2018.11.29 801119661308 2019-02-09 03:57:52
ami-0eb2b3a8214fdeca7 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Web-2018.11.29 801119661308 2019-02-09 03:57:46
ami-045d0d56795653e4a Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Standard-2018.11.29 801119661308 2019-02-09 03:57:40
ami-0120dcaf9a28bc53c Windows_Server-2012-RTM-Japanese-64Bit-Base-2018.11.29 801119661308 2019-02-09 03:56:46
ami-0deeb9b8d2c8827e8 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Web-2018.11.29 801119661308 2019-02-09 03:54:38
ami-0d469dc08622b76cd Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Standard-2018.11.29 801119661308 2019-02-09 03:54:31
ami-02ac79cc77dfb18cb Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Express-2018.11.29 801119661308 2019-02-09 03:54:25
ami-026240680e726276b Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Enterprise-2018.11.29 801119661308 2019-02-09 03:54:18
ami-0ee657259869d0035 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2018.11.29 801119661308 2019-02-09 03:54:11
ami-08966538da1cfd4e2 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Express-2019.02.09 801119661308 2019-02-09 00:15:54
ami-0afb1d8c594def41c Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Web-2019.02.09 801119661308 2019-02-08 23:43:24
ami-0d9f8de6756a0e04a Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Standard-2019.02.09 801119661308 2019-02-08 23:43:19
ami-0003711d008ac685a Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Express-2019.02.09 801119661308 2019-02-08 23:43:13
ami-0358fb8593e5c2c77 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Express-2018.11.29 801119661308 2019-02-08 23:42:23
ami-0b8ccb2df197da68f Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Standard-2018.11.29 801119661308 2019-02-08 23:42:17
ami-035391b5a7e930c68 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Express-2019.02.09 801119661308 2019-02-08 23:42:01
ami-035ba45e14ffb7c5a Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Express-2018.12.13 801119661308 2019-02-08 23:39:09
ami-0d7d685743d764d71 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Web-2019.02.09 801119661308 2019-02-08 23:33:19
ami-0b6a0e2c2c405ba40 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP3_Standard-2019.02.09 801119661308 2019-02-08 23:33:13
ami-011fb54cd32cd8f99 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Web-2019.02.09 801119661308 2019-02-08 23:33:06
ami-0ae123a7f7029a475 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Express-2019.02.09 801119661308 2019-02-08 23:32:36
ami-0d8ce04e50e24aa9e Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Web-2019.02.09 801119661308 2019-02-08 23:32:29
ami-07e213925ea2d6251 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Standard-2019.02.09 801119661308 2019-02-08 23:32:22
ami-05f0a4f049811173c Windows_Server-2012-RTM-Japanese-64Bit-SQL_2012_SP4_Express-2019.02.09 801119661308 2019-02-08 23:32:16
ami-0a38708791c1057af Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Express-2019.02.09 801119661308 2019-02-08 23:31:43
ami-0d778a537b259911b Windows_Server-2012-RTM-Japanese-64Bit-Base-2019.02.09 801119661308 2019-02-08 23:31:37
ami-06134c3630c863a4a Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Standard-2019.02.09 801119661308 2019-02-08 23:25:21
ami-010b6887cbb263707 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Express-2019.02.09 801119661308 2019-02-08 23:25:14
ami-02f01524f887874c5 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Enterprise-2019.02.09 801119661308 2019-02-08 23:25:09
ami-0335d9d836cae7487 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Web-2019.02.09 801119661308 2019-02-08 23:25:03
ami-056ab722ccbf59678 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Standard-2019.02.09 801119661308 2019-02-08 23:24:58
ami-029fd6ef3f73a0d8c Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Express-2019.02.09 801119661308 2019-02-08 23:24:51
ami-0fede383f39b68fa2 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP3_Standard-2019.02.09 801119661308 2019-02-08 23:24:19
ami-07868e500e45fdaba Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP3_Express-2019.02.09 801119661308 2019-02-08 23:24:14
ami-06c99da1acfb4e048 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2019.02.09 801119661308 2019-02-08 23:24:09
ami-0dcc9b8cd7f5edae7 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Express-2019.02.09 801119661308 2019-02-08 23:24:04
ami-05ab604827d5d5296 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Web-2018.12.13 801119661308 2019-02-08 23:23:46
ami-0e27a82d8192996d6 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Web-2018.12.13 801119661308 2019-02-08 23:23:40
ami-0e0d15a66f49ce643 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Express-2018.12.13 801119661308 2019-02-08 23:23:33
ami-0e3ca718197babc1e Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2014_SP2_Express-2018.11.29 801119661308 2019-02-08 23:16:19
ami-0a82d2d398ba08811 Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Enterprise-2019.02.09 801119661308 2019-02-08 22:59:48
ami-04b57d4a0ca7d1c09 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Web-2019.02.09 801119661308 2019-02-08 22:59:43
ami-07e764b3a127cd146 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Standard-2019.02.09 801119661308 2019-02-08 22:59:37
ami-0ea315a27efff7b1d Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Enterprise-2019.02.09 801119661308 2019-02-08 22:59:29
ami-0078d667c94eaf544 Windows_Server-2016-Japanese-Full-Base-2019.02.09 801119661308 2019-02-08 22:59:23
ami-0225312b405dc66e5 Windows_Server-2012-RTM-Japanese-64Bit-SQL_2014_SP2_Standard-2019.02.09 801119661308 2019-02-08 22:54:56
ami-0608f8d28f7fe7c2e Windows_Server-2012-RTM-Japanese-64Bit-SQL_2008_R2_SP3_Standard-2019.02.09 801119661308 2019-02-08 22:54:50
ami-02fe42b588fbf17dd Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP2_Web-2019.02.09 801119661308 2019-02-08 22:52:24
ami-0225dc492065432b9 Windows_Server-2012-R2_RTM-Japanese-64Bit-SQL_2016_SP1_Enterprise-2019.02.09 801119661308 2019-02-08 22:52:15
ami-0e01f589a202be11b Windows_Server-2012-R2_RTM-Japanese-64Bit-Base-2019.02.09 801119661308 2019-02-08 22:52:04
ami-0a96b5a7922879209 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Web-2018.11.29 801119661308 2019-02-08 22:11:53
ami-081f2fa5c962b26c3 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Standard-2018.11.29 801119661308 2019-02-08 22:11:47
ami-063cc92485072d8f8 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Express-2018.11.29 801119661308 2019-02-08 22:11:41
ami-065dbf37d77c50470 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Enterprise-2018.11.29 801119661308 2019-02-08 22:11:35
ami-0e45272e02276221e Windows_Server-2016-Japanese-Full-Base-2018.11.29 801119661308 2019-02-08 18:35:46
ami-0ff0a16a2ce9ee1d5 Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Web-2018.12.13 801119661308 2019-02-08 12:18:19
ami-09c95ca1cf3cca98d Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Standard-2018.12.13 801119661308 2019-02-08 12:18:13
ami-0146aabc4a0fd8494 Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Express-2018.12.13 801119661308 2019-02-08 12:18:06
ami-0e00fbdfadecbdc2a Windows_Server-2016-Japanese-Full-SQL_2016_SP2_Enterprise-2018.12.13 801119661308 2019-02-08 12:18:00
ami-0cc870f6f83d55f1c Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Enterprise-2018.12.13 801119661308 2019-02-08 12:16:44
ami-0d371e92fbd515725 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Web-2018.12.13 801119661308 2019-02-08 11:37:59
ami-04acd60bc723b3d30 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Standard-2018.12.13 801119661308 2019-02-08 11:37:53
ami-0effff44be6e07c11 Windows_Server-2016-Japanese-Full-SQL_2016_SP1_Express-2018.12.13 801119661308 2019-02-08 11:37:46
ami-091d1f7958c2af34d Windows_Server-2016-Japanese-Full-Base-2018.12.13 801119661308 2019-02-08 11:37:37
ami-060f9bc56467435ee Windows_Server-2019-Japanese-Full-Base-2018.12.13 801119661308 2019-02-08 11:19:17
real 0m9.034s
user 0m0.732s
sys 0m0.056s
■1年間の無料枠のWindowsサーバはリージョン「ap-northeast-1」を指定する必要がある点に注意する。
なるほどー。これがリージョンサービスってやつか。
$ grep region .aws/config
region = ap-northeast-1
$ echo -e 'ami-06fb037fb7258dee2\nami-04568cdbd4ceef482' | \
awk '{print "aws ec2 describe-images --image-ids "$1" --query \047Images[].[Name, ImageId, OwnerId]\047 --output text"}' | sh
Windows_Server-2019-English-Full-ContainersLatest-2019.02.09 ami-06fb037fb7258dee2 801119661308
Windows_Server-2019-English-Full-Base-2019.02.09 ami-04568cdbd4ceef482 801119661308
■起動ステータスの確認
$ aws ec2 describe-instance-status --output text | sed -e 's/\ti-.*/\ti-XXXXXXXXXXXXXXXXX/'
INSTANCESTATUSES ap-northeast-1a i-XXXXXXXXXXXXXXXXX
INSTANCESTATE 16 running
INSTANCESTATUS ok
DETAILS reachability passed
SYSTEMSTATUS ok
DETAILS reachability passed
■セキュリティグループやVPCはAWSコンソールウィザードから自動的に作成されたものなので、
入力方向の0.0.0.0/0からのTCP/3389通信が許可されている。
ルーティングテーブルでlocalと定義されているVPCサブネット「172.31.0.0/16」を
更にAZ毎(/20)で区切ったサブネットの内、ap-northeast-1aで稼働中の
プライベートIPに、グローバルIPアドレスが割り当てられていることが分かる。
$ aws ec2 describe-instances --query 'Reservations[].Instances[].SecurityGroups' --output text | \
sed -e 's/sg-................./sg-XXXXXXXXXXXXXXXXX/'
sg-XXXXXXXXXXXXXXXXX launch-wizard-1
$ aws ec2 describe-security-groups --group-name launch-wizard-1 --query 'SecurityGroups[].IpPermissions' --output text
3389 tcp 3389
IPRANGES 0.0.0.0/0
$ aws ec2 describe-route-tables --query 'RouteTables[].Routes' --output text
172.31.0.0/16 local CreateRouteTable active
0.0.0.0/0 igw-41bfe125 CreateRoute active
$ aws ec2 describe-vpcs --query Vpcs[].[CidrBlock,IsDefault,InstanceTenancy] --output text
172.31.0.0/16 True default
$ aws ec2 describe-subnets --filter 'Name=availabilityZone,Values=ap-northeast-1a' --query 'Subnets[].CidrBlock' --output text
172.31.32.0/20
$ aws ec2 describe-network-interfaces \
--query 'NetworkInterfaces[].PrivateIpAddresses[].[Association.PublicIp,PrivateIpAddress]' \
--output text | sed -e 's/\([0-9]*\.[0-9]*\.\)[0-9]*\.[0-9]*/\1X.X/g'
13.112.X.X 172.31.X.X
■その他、費用というかスペックに関連する種別情報
$ aws ec2 describe-instances \
--query 'Reservations[].Instances[].[VirtualizationType,RootDeviceName,RootDeviceType,Platform,Architecture,InstanceType]' \
--output text
hvm /dev/sda1 ebs windows x86_64 t2.micro