Vagrantでインスタンスを指定したVPC subnet配下で起動してEIPを割り当てる方法
指定したVPCのSubnetにvagrant up --provider=awsでインスタンスを起動する方法です。
現時点でvagrant-awsのREADME.mdに下記のようなことが書いてあったけど、動かなかったので
- README.md
associate_public_ip - If true, will associate a public IP address to an instance in a VPC.
- やってみた結果
AWS Provider: * The following settings shouldn't exist: public_ip_address
・・・
- 対応
Issue読んでみるとelastic_ipパラメータがあるらしい
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
attributes = YAML.load_file(".aws/config.yml")
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "dummy"
config.omnibus.chef_version = :latest
config.vm.provider :aws do |aws, override|
aws.tags = attributes["aws_provider"]["tags"]
aws.access_key_id = attributes["aws_provider"]["access_key_id"]
aws.secret_access_key = attributes["aws_provider"]["secret_access_key"]
aws.keypair_name = attributes["aws_provider"]["keypair_name"]
aws.region = attributes["aws_provider"]["region"]
aws.ami = "ami-99107d98" #suz_lab_centos-core-6.5.1
aws.instance_type = attributes["aws_provider"]["instance_type"]
aws.security_groups = attributes["aws_provider"]["security_groups"]
aws.subnet_id = attributes["aws_provider"]["subnet_id"]
aws.elastic_ip = true
override.ssh.username = attributes["aws_provider"]["ssh_username"]
override.ssh.private_key_path = attributes["aws_provider"]["ssh_private_key_path"]
end
end
終わりです。