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

Commit

Permalink
Support passing instance type in environment config file
Browse files Browse the repository at this point in the history
[#156854214] Operators should default to booting 5th generation AWS OpsManager VMs

Signed-off-by: Kalai Wei <[email protected]>
  • Loading branch information
kvedurmu authored and Kalai Wei committed Mar 28, 2019
1 parent 73fa1f8 commit a4604fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/vm_shepherd/aws_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def instance_create_params(ami_file_path, vm_config)
key_name: vm_config.fetch('key_name'),
security_group_ids: [env_config.fetch('outputs').fetch('security_group')],
subnet: env_config.fetch('outputs').fetch('public_subnet_id'),
instance_type: OPS_MANAGER_INSTANCE_TYPE
instance_type: vm_config.dig('instance_type') || OPS_MANAGER_INSTANCE_TYPE
}

if (instance_profile = env_config.fetch('outputs').fetch('instance_profile', nil))
Expand Down
21 changes: 21 additions & 0 deletions spec/vm_shepherd/aws_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,27 @@ module VmShepherd
end
end

context 'when the instance type is specified in the vm config' do
let(:vm_config) do
{
'vm_name' => 'some-vm-name',
'key_name' => 'ssh-key-name',
'instance_type' => 't3.medium'
}
end

it 'creates an instance' do
expect(ec2).to receive_message_chain(:instances, :create).with(
image_id: ami_id,
key_name: 'ssh-key-name',
security_group_ids: ['security-group-id'],
subnet: 'public-subnet-id',
instance_type: 't3.medium').and_return(instance)

ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
end
end

context 'when the ip address is in use' do
it 'retries until the IP address is available' do
expect(instances).to receive(:create).and_raise(AWS::EC2::Errors::InvalidIPAddress::InUse).once
Expand Down

0 comments on commit a4604fe

Please sign in to comment.