8
7

More than 5 years have passed since last update.

VagrantでEC2

Last updated at Posted at 2015-07-13

vagrant-awsの0.6.0では、rsyncに失敗するので、明示的に0.5.0をインストールする。

vagrant plugin install vagrant-aws --plugin-version 0.5.0

Vagrantfileは下記を参照。

このままだと下記のWarningが出るので、

DEPRECATION WARNING: called deprecated method `access_key_id' of an Aws::CredentialProvider, use #credentials instead
DEPRECATION WARNING: called deprecated method `secret_access_key' of an Aws::CredentialProvider, use #credentials instead

下記のように修正。

Vagrantfile
require "aws-sdk";

credentials = Aws::SharedCredentials.new

Vagrant.configure("2") do |config|
  config.vm.box = "dummy"

  config.vm.provider :aws do |aws, override|
    aws.access_key_id = credentials.credentials.access_key_id
    aws.secret_access_key = credentials.credentials.secret_access_key
    aws.region = 'ap-northeast-1'
    aws.instance_type = 't2.micro'    
    aws.ami = 'ami-cbf90ecb'
    aws.security_groups = ['test_group']
    aws.keypair_name = 'test_key'
    aws.tags = { 
      'Name' => 'test-vagrant'
    }
    override.ssh.username = "ec2-user"
    override.ssh.private_key_path = 'sshkeyfile'
    override.ssh.pty = true
  end
end
8
7
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
8
7