Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

vagrant aws: adding associate public ip functionality #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ These rules are cleared on restart. They can be saved and configured to be reloa

|Name|Description|Default|
|---|---|---|
|BOSH_AWS_ACCESS_KEY_ID |AWS access key ID | |
|BOSH_AWS_SECRET_ACCESS_KEY |AWS secret access key | |
|BOSH_LITE_KEYPAIR |AWS keypair name |bosh|
|BOSH_LITE_NAME |AWS instance name |Vagrant|
|BOSH_LITE_SECURITY_GROUP |AWS security group |inception|
|BOSH_LITE_PRIVATE_KEY |path to private key matching keypair |~/.ssh/id_rsa_bosh|
|[VPC only] BOSH_LITE_SUBNET_ID |AWS VPC subnet ID | |
|BOSH_AWS_ACCESS_KEY_ID |AWS access key ID | |
|BOSH_AWS_SECRET_ACCESS_KEY |AWS secret access key | |
|BOSH_LITE_KEYPAIR |AWS keypair name |bosh|
|BOSH_LITE_NAME |AWS instance name |Vagrant|
|BOSH_LITE_SECURITY_GROUP |AWS security group |inception|
|BOSH_LITE_PRIVATE_KEY |path to private key matching keypair |~/.ssh/id_rsa_bosh|
|[VPC only] BOSH_LITE_SUBNET_ID |AWS VPC subnet ID | |
|[VPC only] BOSH_LITE_ASSOCIATE_PUBLIC_IP |Associate a public ip to the VPC instance | false |

## Restart the Director

Expand Down
9 changes: 6 additions & 3 deletions aws/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Vagrant.configure('2') do |config|
# better error messages from Hash.fetch
env = ENV.to_hash

associate_public_ip = ( ['true','1'].include? env.fetch('BOSH_LITE_ASSOCIATE_PUBLIC_IP').downcase ) if env.include?('BOSH_LITE_ASSOCIATE_PUBLIC_IP')

config.vm.box = 'dummy'
config.vm.box_url = 'https://github.com/mitchellh/vagrant-aws/blob/master/dummy.box?raw=true'
config.vm.provider :aws do |aws, override|
Expand All @@ -37,12 +39,13 @@ Vagrant.configure('2') do |config|
aws.security_groups = [ env.fetch('BOSH_LITE_SECURITY_GROUP', 'inception') ]

aws.subnet_id = env.fetch('BOSH_LITE_SUBNET_ID') if env.include?('BOSH_LITE_SUBNET_ID')

aws.associate_public_ip = associate_public_ip

override.ssh.username = 'ubuntu'
override.ssh.private_key_path = env.fetch('BOSH_LITE_PRIVATE_KEY', '~/.ssh/id_rsa_bosh')
end

endpoint = env.include?('BOSH_LITE_SUBNET_ID') ? 'local-ipv4' : 'public-ipv4'
endpoint = ( associate_public_ip or not env.include?('BOSH_LITE_SUBNET_ID') ) ? 'public-ipv4' : 'local-ipv4'

PORT_FORWARDING = <<-IP_SCRIPT
ip=`curl -s http://169.254.169.254/latest/meta-data/#{endpoint}`
Expand All @@ -56,4 +59,4 @@ IP_SCRIPT

config.vm.provision :shell, :inline => PORT_FORWARDING

end
end