AWS上に素早く環境を構築する
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfras...
-戻る
--[[開発環境]]
--[[Azureの場合>#w3b5f47b]]
--[[Amazon EC2]]
---[[AWSの評価環境を入手する]]
---AWS上に素早く環境を構築する
*目次 [#j73e88e1]
#contents
*概要 [#h37db14e]
「[[Azure上に素早く環境を構築する>https://techinfoofmicro...
*詳細 [#iaf9a2dc]
取り敢えず、AWSの新しいVM Import、~
[[ImportImage>#ee7cc0b1]]を使用してみようかと。
**VHDのImportImage [#ee7cc0b1]
-取り敢えず、Azure VMのVHDを使ってAWS VMを起動してみよう...
-「[[VM起動後の開発環境のセットアップ]]」の手順で作成した...
--Windows10は、BYOL が必要。
--また、第 2 世代 VMの設定なども、現時点では、良く解らな...
>との事で、Windows Server + Docker Desktop 程度をテストし...
***[[AWS CLI]]の設定 [#d65f9cdc]
-AWS CLIをインストールする。
-[[専用のIAMユーザ(vmimportuser)を作成>AWS CLI#mee40dca...
--IAMユーザを新規作成し、下記のグループ&ポリシを適用。
--IAMユーザのkeyとsecretを取得する。
-keyとsecret, etc. を[[AWS CLIに設定>AWS CLI#n6b78cfa]]
-グループ&ポリシの作成ポイント
--管理ポリシでも良いのかも知れないが、権限をミニマムに出...
--[[手順の例>#ge5fcf60]]に以下の様なミニマムなポリシ設定...
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:DeleteObject",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": ["arn:aws:s3:::import-to-ec2-vhdbucket...
},
{
"Effect": "Allow",
"Action": [
"ec2:CancelConversionTask",
"ec2:CancelExportTask",
"ec2:CreateImage",
"ec2:CreateInstanceExportTask",
"ec2:CreateTags",
"ec2:DeleteTags",
"ec2:DescribeConversionTasks",
"ec2:DescribeExportTasks",
"ec2:DescribeInstanceAttribute",
"ec2:DescribeInstanceStatus",
"ec2:DescribeInstances",
"ec2:DescribeTags",
"ec2:ImportInstance",
"ec2:ImportVolume",
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:TerminateInstances",
"ec2:ImportImage",
"ec2:ImportSnapshot",
"ec2:DescribeImportImageTasks",
"ec2:DescribeImportSnapshotTasks",
"ec2:CancelImportTask"
],
"Resource": "*"
}
]
}
--ただ、上記では、CLIで、以下の操作ができない。
---ロールの作成 → AdministratorAccess管理ポリシを追加
***VHDの準備と利用 [#g2d07726]
-EC2にインポートしたいVMイメージ(ココではVHD)を用意
--AzureでWindows ServerのVMを作成
--RDP接続を既定のポートで有効しておく。
--アカウント情報はメモしておく。
--起動して接続を確認した後、停止する。
--VHDをダウンロードする。~
...と思ったが、AzureのOS Discは127GiBから縮小できないよう...
別途、評価版のVHDを入手し、Hyper-V上で初期化し、アップロ...
(127GiBをダウンロードしてアップロードするには、数日間掛...
-VMイメージ(ココではVHD)をアップロードするためのs3のbuc...
--import-to-ec2-vhdbucketというs3bucketを作成
---CLI~
>aws s3api create-bucket --bucket import-to-ec2-vhdbucke...
--------------------------------------------------------...
| CreateBucket ...
+----------+--------------------------------------------...
| Location| http://import-to-ec2-vhdbucket.s3.amazonaw...
+----------+--------------------------------------------...
---ポータルからも作成可能。
-VHDのアップロードとAMI(Amazon Machine Image)化、
--VHDをimport-to-ec2-vhdbucketにアップロード
---CLI~
>aws s3 cp C:\...\xxxx.vhd s3://import-to-ec2-vhdbucket
upload: ..\..\xxxx.vhd to s3://import-to-ec2-vhdbucket/x...
>aws s3 ls s3://import-to-ec2-vhdbucket
2020-xx-xx xx:xx:xx 9692336128 xxxx.vhd
---ポータルからもアップロード可能。
--VM Import [[ロール>AWS IAM#z02d8227]]を設定
---ロール作成リクエスト用のjson(trust-policy.json)を作...
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "vmie.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals":{
"sts:Externalid": "vmimport"
}
}
}
]
}
※ 「"sts:Externalid": "vmimport"」をしていしているが、~
自分で直接「sts assume-role」をしてないので、~
--external-idパラメタのベースが何なのか不明と言う。
---ロール作成リクエストを投げる。
aws iam create-role --role-name vmimport --assume-role-p...
---(ロールへの)ポリシ設定リクエスト用のjson(role-polic...
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::import-to-ec2-vhdbucket"
]
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::import-to-ec2-vhdbucket/*"
]
},
{
"Effect": "Allow",
"Action":[
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*"
],
"Resource": "*"
}
]
}
---(サービスが使用する)(ロールへの)ポリシ設定リクエス...
aws iam put-role-policy --role-name vmimport --policy-na...
--VHDをAMIに変換する。
---AMI変換リクエスト用のjson(containers.json)を作成する。
[
{
"Description": "Windows 20XX VHD",
"Format": "vhd",
"UserBucket": {
"S3Bucket": "import-to-ec2-vhdbucket",
"S3Key": "xxxx.vhd"
}
}
]
---AMI変換リクエストを投げる。
>aws ec2 import-image --cli-input-json file://"C:\...\co...
---進捗を確認しつつ待つ~
初回(ImportTaskIdを確認)
>aws ec2 describe-import-image-tasks
-----------------------------------------------------
| DescribeImportImageTasks |
+---------------------------------------------------+
|| ImportImageTasks ||
|+----------------+--------------------------------+|
|| Description | Windows 20xx VHD ||
|| ImportTaskId | import-ami-xxxxxxxxxxxxxxxxx ||
|| Progress | 19 ||
|| Status | active ||
|| StatusMessage | converting ||
|+----------------+--------------------------------+|
||| SnapshotDetails |||
||+----------------------+------------------------+||
||| Description | First CLI task |||
||| DiskImageSize | 9692336128.0 |||
||| Format | VHD |||
||| Status | active |||
||+----------------------+------------------------+||
|||| UserBucket ||||
|||+------------+--------------------------------+|||
|||| S3Bucket | import-to-ec2-vhdbucket ||||
|||| S3Key | xxxx.vhd ||||
|||+------------+--------------------------------+|||
~
初回以降(ImportTaskIdを指定)
>aws ec2 describe-import-image-tasks --import-task-ids i...
-----------------------------------------------------
| DescribeImportImageTasks |
+---------------------------------------------------+
|| ImportImageTasks ||
|+----------------+--------------------------------+|
|| Architecture | x86_64 ||
|| Description | Windows 20xx VHD ||
|| ImageId | ami-xxxxxxxxxxxxxxxxx ||
|| ImportTaskId | import-ami-xxxxxxxxxxxxxxxxxx ||
|| LicenseType | AWS ||
|| Platform | Windows ||
|| Progress | 58 ||
|| Status | active ||
|| StatusMessage | preparing ami ||
|+----------------+--------------------------------+|
||| SnapshotDetails |||
||+-----------------+-----------------------------+||
||| Description | First CLI task |||
||| DeviceName | /dev/sda1 |||
||| DiskImageSize | 9692336128.0 |||
||| Format | VHD |||
||| SnapshotId | snap-xxxxxxxxxxxxxxxxx |||
||| Status | completed |||
||+-----------------+-----------------------------+||
|||| UserBucket ||||
|||+------------+--------------------------------+|||
|||| S3Bucket | import-to-ec2-vhdbucket ||||
|||| S3Key | xxxx.vhd ||||
|||+------------+--------------------------------+|||
~
なんだか、VHDの中身を勝手にWindows or Linuxって検知して...
-VHD → AMI変換完了後、AMIを使用してインスタンスを作成。
--EC2のポータルから、マイAMIを使用して、インスタンスを作...
--なお、ログインの際のユーザ・アカウントは、元のVHDのアカ...
**CloudEndure Migration [#pc302a78]
AWSの、高度に自動化されたクラウド移行ソリューションらしい。
***, etc. [#yf8fa5db]
*参考 [#t7d8723b]
**[[Azure上に素早く環境を構築する>開発環境#t293de7c]] [#w...
**[[AWSの評価環境を入手する]] [#t3d613fa]
**[[VM起動後の開発環境のセットアップ]] [#r45f7425]
**その他 [#f54a83a3]
***手順の例 [#ge5fcf60]
-[[[AWS CLI]手元の仮想マシンをEC2に移行するときにドハマり...
-VM Importでイメージインポートしてみた | Developers.IO~
https://dev.classmethod.jp/articles/vm-import-image-import/
-EC2 instance assume Role to use AWS VM Import – ExploitN...
https://exploitnetworking.com/en/aws-en/ec2-instance-assu...
***Qiita [#m71f96df]
-ImportImageによるVMインポート~
https://qiita.com/ryo0301/items/e36f7602fbd762e739b2
-AWS CLIでVMwareイメージをインポート~
https://qiita.com/toguma/items/7ae15a7bc469608d3d72
-ウサギでもできるAWSへの~
サーバーマイグレーション~
~CloudEndureでやってみた~~
https://qiita.com/issie_/items/814e727677148cd0fcd5
***AWS [#p3b44c6e]
-よくある質問 - AWS と Microsoft~
https://aws.amazon.com/jp/windows/faq/
- VM Import/Export
--VM Import/Export Requirements~
https://docs.aws.amazon.com/ja_jp/vm-import/latest/usergu...
--Importing a VM as an Image Using VM Import/Export~
https://docs.aws.amazon.com/ja_jp/vm-import/latest/usergu...
終了行:
「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfras...
-戻る
--[[開発環境]]
--[[Azureの場合>#w3b5f47b]]
--[[Amazon EC2]]
---[[AWSの評価環境を入手する]]
---AWS上に素早く環境を構築する
*目次 [#j73e88e1]
#contents
*概要 [#h37db14e]
「[[Azure上に素早く環境を構築する>https://techinfoofmicro...
*詳細 [#iaf9a2dc]
取り敢えず、AWSの新しいVM Import、~
[[ImportImage>#ee7cc0b1]]を使用してみようかと。
**VHDのImportImage [#ee7cc0b1]
-取り敢えず、Azure VMのVHDを使ってAWS VMを起動してみよう...
-「[[VM起動後の開発環境のセットアップ]]」の手順で作成した...
--Windows10は、BYOL が必要。
--また、第 2 世代 VMの設定なども、現時点では、良く解らな...
>との事で、Windows Server + Docker Desktop 程度をテストし...
***[[AWS CLI]]の設定 [#d65f9cdc]
-AWS CLIをインストールする。
-[[専用のIAMユーザ(vmimportuser)を作成>AWS CLI#mee40dca...
--IAMユーザを新規作成し、下記のグループ&ポリシを適用。
--IAMユーザのkeyとsecretを取得する。
-keyとsecret, etc. を[[AWS CLIに設定>AWS CLI#n6b78cfa]]
-グループ&ポリシの作成ポイント
--管理ポリシでも良いのかも知れないが、権限をミニマムに出...
--[[手順の例>#ge5fcf60]]に以下の様なミニマムなポリシ設定...
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:DeleteObject",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": ["arn:aws:s3:::import-to-ec2-vhdbucket...
},
{
"Effect": "Allow",
"Action": [
"ec2:CancelConversionTask",
"ec2:CancelExportTask",
"ec2:CreateImage",
"ec2:CreateInstanceExportTask",
"ec2:CreateTags",
"ec2:DeleteTags",
"ec2:DescribeConversionTasks",
"ec2:DescribeExportTasks",
"ec2:DescribeInstanceAttribute",
"ec2:DescribeInstanceStatus",
"ec2:DescribeInstances",
"ec2:DescribeTags",
"ec2:ImportInstance",
"ec2:ImportVolume",
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:TerminateInstances",
"ec2:ImportImage",
"ec2:ImportSnapshot",
"ec2:DescribeImportImageTasks",
"ec2:DescribeImportSnapshotTasks",
"ec2:CancelImportTask"
],
"Resource": "*"
}
]
}
--ただ、上記では、CLIで、以下の操作ができない。
---ロールの作成 → AdministratorAccess管理ポリシを追加
***VHDの準備と利用 [#g2d07726]
-EC2にインポートしたいVMイメージ(ココではVHD)を用意
--AzureでWindows ServerのVMを作成
--RDP接続を既定のポートで有効しておく。
--アカウント情報はメモしておく。
--起動して接続を確認した後、停止する。
--VHDをダウンロードする。~
...と思ったが、AzureのOS Discは127GiBから縮小できないよう...
別途、評価版のVHDを入手し、Hyper-V上で初期化し、アップロ...
(127GiBをダウンロードしてアップロードするには、数日間掛...
-VMイメージ(ココではVHD)をアップロードするためのs3のbuc...
--import-to-ec2-vhdbucketというs3bucketを作成
---CLI~
>aws s3api create-bucket --bucket import-to-ec2-vhdbucke...
--------------------------------------------------------...
| CreateBucket ...
+----------+--------------------------------------------...
| Location| http://import-to-ec2-vhdbucket.s3.amazonaw...
+----------+--------------------------------------------...
---ポータルからも作成可能。
-VHDのアップロードとAMI(Amazon Machine Image)化、
--VHDをimport-to-ec2-vhdbucketにアップロード
---CLI~
>aws s3 cp C:\...\xxxx.vhd s3://import-to-ec2-vhdbucket
upload: ..\..\xxxx.vhd to s3://import-to-ec2-vhdbucket/x...
>aws s3 ls s3://import-to-ec2-vhdbucket
2020-xx-xx xx:xx:xx 9692336128 xxxx.vhd
---ポータルからもアップロード可能。
--VM Import [[ロール>AWS IAM#z02d8227]]を設定
---ロール作成リクエスト用のjson(trust-policy.json)を作...
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "vmie.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals":{
"sts:Externalid": "vmimport"
}
}
}
]
}
※ 「"sts:Externalid": "vmimport"」をしていしているが、~
自分で直接「sts assume-role」をしてないので、~
--external-idパラメタのベースが何なのか不明と言う。
---ロール作成リクエストを投げる。
aws iam create-role --role-name vmimport --assume-role-p...
---(ロールへの)ポリシ設定リクエスト用のjson(role-polic...
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::import-to-ec2-vhdbucket"
]
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::import-to-ec2-vhdbucket/*"
]
},
{
"Effect": "Allow",
"Action":[
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*"
],
"Resource": "*"
}
]
}
---(サービスが使用する)(ロールへの)ポリシ設定リクエス...
aws iam put-role-policy --role-name vmimport --policy-na...
--VHDをAMIに変換する。
---AMI変換リクエスト用のjson(containers.json)を作成する。
[
{
"Description": "Windows 20XX VHD",
"Format": "vhd",
"UserBucket": {
"S3Bucket": "import-to-ec2-vhdbucket",
"S3Key": "xxxx.vhd"
}
}
]
---AMI変換リクエストを投げる。
>aws ec2 import-image --cli-input-json file://"C:\...\co...
---進捗を確認しつつ待つ~
初回(ImportTaskIdを確認)
>aws ec2 describe-import-image-tasks
-----------------------------------------------------
| DescribeImportImageTasks |
+---------------------------------------------------+
|| ImportImageTasks ||
|+----------------+--------------------------------+|
|| Description | Windows 20xx VHD ||
|| ImportTaskId | import-ami-xxxxxxxxxxxxxxxxx ||
|| Progress | 19 ||
|| Status | active ||
|| StatusMessage | converting ||
|+----------------+--------------------------------+|
||| SnapshotDetails |||
||+----------------------+------------------------+||
||| Description | First CLI task |||
||| DiskImageSize | 9692336128.0 |||
||| Format | VHD |||
||| Status | active |||
||+----------------------+------------------------+||
|||| UserBucket ||||
|||+------------+--------------------------------+|||
|||| S3Bucket | import-to-ec2-vhdbucket ||||
|||| S3Key | xxxx.vhd ||||
|||+------------+--------------------------------+|||
~
初回以降(ImportTaskIdを指定)
>aws ec2 describe-import-image-tasks --import-task-ids i...
-----------------------------------------------------
| DescribeImportImageTasks |
+---------------------------------------------------+
|| ImportImageTasks ||
|+----------------+--------------------------------+|
|| Architecture | x86_64 ||
|| Description | Windows 20xx VHD ||
|| ImageId | ami-xxxxxxxxxxxxxxxxx ||
|| ImportTaskId | import-ami-xxxxxxxxxxxxxxxxxx ||
|| LicenseType | AWS ||
|| Platform | Windows ||
|| Progress | 58 ||
|| Status | active ||
|| StatusMessage | preparing ami ||
|+----------------+--------------------------------+|
||| SnapshotDetails |||
||+-----------------+-----------------------------+||
||| Description | First CLI task |||
||| DeviceName | /dev/sda1 |||
||| DiskImageSize | 9692336128.0 |||
||| Format | VHD |||
||| SnapshotId | snap-xxxxxxxxxxxxxxxxx |||
||| Status | completed |||
||+-----------------+-----------------------------+||
|||| UserBucket ||||
|||+------------+--------------------------------+|||
|||| S3Bucket | import-to-ec2-vhdbucket ||||
|||| S3Key | xxxx.vhd ||||
|||+------------+--------------------------------+|||
~
なんだか、VHDの中身を勝手にWindows or Linuxって検知して...
-VHD → AMI変換完了後、AMIを使用してインスタンスを作成。
--EC2のポータルから、マイAMIを使用して、インスタンスを作...
--なお、ログインの際のユーザ・アカウントは、元のVHDのアカ...
**CloudEndure Migration [#pc302a78]
AWSの、高度に自動化されたクラウド移行ソリューションらしい。
***, etc. [#yf8fa5db]
*参考 [#t7d8723b]
**[[Azure上に素早く環境を構築する>開発環境#t293de7c]] [#w...
**[[AWSの評価環境を入手する]] [#t3d613fa]
**[[VM起動後の開発環境のセットアップ]] [#r45f7425]
**その他 [#f54a83a3]
***手順の例 [#ge5fcf60]
-[[[AWS CLI]手元の仮想マシンをEC2に移行するときにドハマり...
-VM Importでイメージインポートしてみた | Developers.IO~
https://dev.classmethod.jp/articles/vm-import-image-import/
-EC2 instance assume Role to use AWS VM Import – ExploitN...
https://exploitnetworking.com/en/aws-en/ec2-instance-assu...
***Qiita [#m71f96df]
-ImportImageによるVMインポート~
https://qiita.com/ryo0301/items/e36f7602fbd762e739b2
-AWS CLIでVMwareイメージをインポート~
https://qiita.com/toguma/items/7ae15a7bc469608d3d72
-ウサギでもできるAWSへの~
サーバーマイグレーション~
~CloudEndureでやってみた~~
https://qiita.com/issie_/items/814e727677148cd0fcd5
***AWS [#p3b44c6e]
-よくある質問 - AWS と Microsoft~
https://aws.amazon.com/jp/windows/faq/
- VM Import/Export
--VM Import/Export Requirements~
https://docs.aws.amazon.com/ja_jp/vm-import/latest/usergu...
--Importing a VM as an Image Using VM Import/Export~
https://docs.aws.amazon.com/ja_jp/vm-import/latest/usergu...
ページ名: