class Bosh::AwsCliPlugin::AwsConfig

Public Class Methods

new(filename, env = ENV) click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 8
def initialize(filename, env = ENV)
  @filename = filename
  @env = env
end

Public Instance Methods

aws_access_key_id() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 28
def aws_access_key_id
  fetch_from_env("BOSH_AWS_ACCESS_KEY_ID")
end
aws_region() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 32
def aws_region
  @env.fetch('BOSH_AWS_REGION', 'us-east-1')
end
aws_secret_access_key() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 24
def aws_secret_access_key
  fetch_from_env("BOSH_AWS_SECRET_ACCESS_KEY")
end
cache_access_key_id() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 114
def cache_access_key_id
  @env["BOSH_CACHE_ACCESS_KEY_ID"]
end
cache_bucket_name() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 126
def cache_bucket_name
  @env.fetch("BOSH_CACHE_BUCKET_NAME", "bosh-global-package-cache")
end
cache_secret_access_key() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 118
def cache_secret_access_key
  unless has_package_cache_configuration?
    raise ConfigurationInvalid, "Missing ENV variable BOSH_CACHE_ACCESS_KEY_ID"
  end

  fetch_from_env("BOSH_CACHE_SECRET_ACCESS_KEY")
end
configuration() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 13
def configuration
  load_configuration(File.read(@filename))
end
director_ssl_cert_file() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 106
def director_ssl_cert_file
  @env.fetch("BOSH_DIRECTOR_SSL_CERT", "director.pem")
end
director_ssl_key_file() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 102
def director_ssl_key_file
  @env.fetch("BOSH_DIRECTOR_SSL_KEY", "director.key")
end
elb_ssl_cert_chain_file() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 98
def elb_ssl_cert_chain_file
  @env["BOSH_AWS_ELB_SSL_CHAIN"]
end
elb_ssl_cert_file() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 94
def elb_ssl_cert_file
  @env.fetch("BOSH_AWS_ELB_SSL_CERT", "elb-cfrouter.pem")
end
elb_ssl_key_file() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 90
def elb_ssl_key_file
  @env.fetch("BOSH_AWS_ELB_SSL_KEY", "elb-cfrouter.key")
end
fetch_from_env(key, msg=nil) click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 17
def fetch_from_env(key, msg=nil)
  @env.fetch(key) {
    msg ||= "Missing ENV variable #{key}"
    raise(ConfigurationInvalid, msg)
  }
end
has_package_cache_configuration?() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 110
def has_package_cache_configuration?
  cache_access_key_id
end
has_vpc_domain?() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 66
def has_vpc_domain?
  vpc_domain && vpc_domain != ""
end
has_vpc_subdomain?() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 70
def has_vpc_subdomain?
  vpc_subdomain && vpc_subdomain != ""
end
key_pair_name() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 82
def key_pair_name
  @env.fetch("BOSH_KEY_PAIR_NAME", "bosh")
end
key_pair_path() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 86
def key_pair_path
  @env.fetch("BOSH_KEY_PATH", "#{@env['HOME']}/.ssh/id_rsa_bosh")
end
load_configuration(yaml) click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 134
def load_configuration(yaml)
  renderer = ERB.new(yaml, 0, '<>%-')

  YAML.load(renderer.result(binding))
end
production_resources?() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 130
def production_resources?
  @env['BOSH_PRODUCTION_RESOURCES']
end
vpc_deployment_name() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 44
def vpc_deployment_name
  if has_vpc_subdomain?
    vpc_subdomain
  elsif has_vpc_domain?
    vpc_domain.gsub('.', '-')
  else
    "deployment"
  end
end
vpc_domain() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 36
def vpc_domain
  @env["BOSH_VPC_DOMAIN"]
end
vpc_generated_domain() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 54
def vpc_generated_domain
  if has_vpc_domain? && has_vpc_subdomain?
    "#{vpc_subdomain}.#{vpc_domain}"
  elsif has_vpc_subdomain?
    "#{vpc_subdomain}.cf-app.com"
  elsif has_vpc_domain?
    vpc_domain
  else
    raise(ConfigurationInvalid, "No domain and subdomain are defined.")
  end
end
vpc_primary_az() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 74
def vpc_primary_az
  fetch_from_env("BOSH_VPC_PRIMARY_AZ")
end
vpc_secondary_az() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 78
def vpc_secondary_az
  fetch_from_env("BOSH_VPC_SECONDARY_AZ")
end
vpc_subdomain() click to toggle source
# File lib/bosh_cli_plugin_aws/aws_config.rb, line 40
def vpc_subdomain
  @env["BOSH_VPC_SUBDOMAIN"]
end