LoginSignup
26
25

More than 5 years have passed since last update.

VagrantでAWSを利用する

Posted at

vagrant-awsのインストール

VagrantでAWSを利用するにはvagrant-awsというナイスなプラグインがある。

vagrant plugin install vagrant-aws

使い方はGitHubで。

Vagrantfileの設定

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "dummy"
  config.vm.provider :aws do |aws, override|
    aws.access_key_id = "ACCESS KEY"
    aws.secret_access_key = "SECRET ACCESS KEY"
    aws.keypair_name = "KEYPAIR"
    aws.ami = "ami-a1124fa0"
    aws.region = "ap-northeast-1"
    override.ssh.username = "ubuntu"
    override.ssh.private_key_path = "/path/to/aws.pem"
  end

  config.vm.define "host1" do |m|
    m.vm.provider :aws do |aws, override|
      aws.instance_type = "t2.micro"
      aws.security_groups = ["default"]
    end
  end

end

Acess Key IDとSecret Access Keyが分からない場合は、AWSのヘルプを参照。

ami-a1124fa0はUbuntu 14.04 LTS 64bit。

インスタンスを立ち上げてみる

vagrant up --provider aws host1

実行の後、AWS Management ConsoleのEC2のInstancesで、新しいインスタンスが立ち上がっているのが確認できる。

26
25
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
26
25