Class: Bosh::Providers::Cli::AwsProviderCli
- Inherits:
-
ProviderCli
- Object
- ProviderCli
- Bosh::Providers::Cli::AwsProviderCli
- Defined in:
- lib/bosh/providers/cli/aws_provider_cli.rb
Overview
Interactively prompt user for region & credential information for AWS
Primary use within inception is to pass settings.provider
hash run #perform to gather credentials, then export the credentials/attributes.
settings["provider"] = {}
provider = AwsProviderCli.new(settings.provider)
provider_client.perform
settings.provider = provider_cli.export_attributes
Instance Attribute Summary
Attributes inherited from ProviderCli
Instance Method Summary collapse
- #aws_constants ⇒ Object
- #choose_region ⇒ Object
-
#export_attributes ⇒ Object
helper to export the complete nested attributes as a pure Hash.
- #perform ⇒ Object
- #setup_credentials ⇒ Object
Methods inherited from ProviderCli
Methods included from Inception::CliHelpers::Interactions
#bold, #clear, #cyan, #green, #hl, #red, #yellow
Constructor Details
This class inherits a constructor from Bosh::Providers::Cli::ProviderCli
Instance Method Details
#aws_constants ⇒ Object
55 56 57 |
# File 'lib/bosh/providers/cli/aws_provider_cli.rb', line 55 def aws_constants Bosh::Providers::Constants::AwsConstants end |
#choose_region ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bosh/providers/cli/aws_provider_cli.rb', line 30 def choose_region hl.choose do || .prompt = "Choose AWS region: " = nil aws_constants.region_labels.each do |region_info| label, code = region_info[:label], region_info[:code] = "#{label} (#{code})" if code == aws_constants.default_region_code = "*#{}" = end .choice() do attributes["region"] = code end end .default = if end end |
#export_attributes ⇒ Object
helper to export the complete nested attributes as a pure Hash
26 27 28 |
# File 'lib/bosh/providers/cli/aws_provider_cli.rb', line 26 def export_attributes attributes.to_nested_hash end |
#perform ⇒ Object
19 20 21 22 23 |
# File 'lib/bosh/providers/cli/aws_provider_cli.rb', line 19 def perform attributes.set("name", "aws") # ensure this property is correct choose_region unless attributes.exists?("region") setup_credentials unless attributes.exists?("credentials.aws_access_key_id") end |
#setup_credentials ⇒ Object
49 50 51 52 53 |
# File 'lib/bosh/providers/cli/aws_provider_cli.rb', line 49 def setup_credentials attributes.set_default("credentials", {}) attributes.credentials["aws_access_key_id"] = hl.ask("Access key: ") attributes.credentials["aws_secret_access_key"] = hl.ask("Secret key: ") end |