39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require_relative "accounts_factory"
 | |
| module Provider
 | |
|   class Ec2AccountsFactory < AccountsFactory
 | |
| 
 | |
|     def init config
 | |
|       @connections = {}
 | |
|       accounts.each do |account|
 | |
|         create_connection_from_account(config, account)
 | |
|         puts "\tFound ec2 account '#{account.account_name}'"
 | |
|       end
 | |
|       ProviderFactory.add_provider Ec2::PROVIDER unless @connections.empty?
 | |
|     end
 | |
| 
 | |
|     def provider_name
 | |
|       Ec2::PROVIDER
 | |
|     end
 | |
| 
 | |
|     def create_connection_from_account config, account
 | |
|        options = {
 | |
|         aws_ssh_key: account.ssh_key,
 | |
|         aws_access_key_id:  account.access_key_id,
 | |
|         aws_secret_access_key: account.secret_access_key,
 | |
|         aws_use_iam_profile: account.use_iam_profile,
 | |
|         aws_availability_zone: account.availability_zone,
 | |
| 
 | |
|         aws_proxy: config[:aws_proxy],
 | |
|         aws_no_proxy: config[:aws_no_proxy],
 | |
|         aws_integration_run_list: config[:aws_integration_run_list]
 | |
|       }
 | |
|       add_connection(account.account_name, Ec2.new(options))
 | |
|     end
 | |
| 
 | |
|     def create_account hash
 | |
|       Devops::Model::Ec2ProviderAccount.new(hash)
 | |
|     end
 | |
| 
 | |
|   end
 | |
| end
 | 
