LoginSignup
9
9

More than 5 years have passed since last update.

EC2作成スクリプトのHVM対応

Last updated at Posted at 2014-08-29

【AWS発表】バースト可能な性能を持つ新しい低コストEC2インスタンスが発表され、よしt1.microをt2.microに切り替えよう!と思ったら、Change Instance Typeで選べない。

T2インスタンスは、基本となるCPUから可能な限り最高の性能を得るために、Hardware Virtualization (HVM)を使用していますので、HVM AMIを使う必要があります。

とあるように、以前のPV(ParaVirtual)形式のものとはAMIの形式が違うので変更はできないようです。
ManagementConsoleのデフォルトAMIもいつのまにか新しい、HVM形式のものになっていました。

移行はまぁまぁ面倒そうなので、Amazon Linuxのインスタンス作成スクリプトを新しいAMIに対応するように修正してインスタンスを作りなおしました。
AMIのID以外に、ブロックデバイスをsdaからxvdaに変える必要がありました。

PVのころ
ec2 = AWS::EC2.new

instance = ec2.instances.create(
  image_id:        'ami-c9562fc8', # Amazon Linux x86_64 PV
  instance_type:   instance_type,
  key_name:        key_name,
  security_group_ids: security_group_ids,
  block_device_mappings: [
    {
      device_name: '/dev/sda1',
      ebs: { volume_size: 30 }
    }
  ]
)
HVMに切り替え
ec2 = AWS::EC2.new

instance = ec2.instances.create(
  image_id:        'ami-29dc9228', # Amazon Linux x86_64 HVM
  instance_type:   instance_type,
  key_name:        key_name,
  security_group_ids: security_group_ids,
  block_device_mappings: [
    {
      device_name: '/dev/xvda',
      ebs: { volume_size: 30 }
    }
  ]
)
9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9