Class: Aws::SharedConfig Private
- Inherits:
-
Object
- Object
- Aws::SharedConfig
- Defined in:
- lib/aws-sdk-core/shared_config.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #config_path ⇒ String readonly private
- #credentials_path ⇒ String readonly private
- #profile_name ⇒ String readonly private
Instance Method Summary collapse
-
#assume_role_credentials_from_config(opts = {}) ⇒ Object
private
Attempts to assume a role from shared config or shared credentials file.
- #assume_role_web_identity_credentials_from_config(profile) ⇒ Object private
-
#config_enabled? ⇒ Boolean
private
Returns
trueif use of the shared config file is enabled. -
#credentials(opts = {}) ⇒ Aws::Credentials
private
Sources static credentials from shared credential/config files.
- #credentials_process(profile) ⇒ Object private
- #csm_client_id(opts = {}) ⇒ Object private
- #csm_enabled(opts = {}) ⇒ Object private
- #csm_host(opts = {}) ⇒ Object private
- #csm_port(opts = {}) ⇒ Object private
- #endpoint_discovery(opts = {}) ⇒ Object private
- #fresh(options = {}) ⇒ Object private
-
#initialize(options = {}) ⇒ SharedConfig
constructor
private
Constructs a new SharedConfig provider object.
-
#loadable?(path) ⇒ Boolean
private
Returns
trueif a credential file exists and has appropriate read permissions at #path. - #region(opts = {}) ⇒ Object private
- #s3_us_east_1_regional_endpoint(opts = {}) ⇒ Object private
- #s3_use_arn_region(opts = {}) ⇒ Object private
- #sts_regional_endpoints(opts = {}) ⇒ Object private
Constructor Details
#initialize(options = {}) ⇒ SharedConfig
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Constructs a new SharedConfig provider object. This will load the shared credentials file, and optionally the shared configuration file, as ini files which support profiles.
By default, the shared credential file (the default path for which is ‘~/.aws/credentials`) and the shared config file (the default path for which is `~/.aws/config`) are loaded. However, if you set the `ENV` environment variable, only the shared credential file will be loaded. You can specify the shared credential file path with the `ENV` environment variable or with the :credentials_path option. Similarly, you can specify the shared config file path with the `ENV` environment variable or with the :config_path option.
The default profile name is ‘default’. You can specify the profile name with the ‘ENV` environment variable or with the :profile_name option.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/aws-sdk-core/shared_config.rb', line 46 def initialize( = {}) @parsed_config = nil @profile_name = determine_profile() @config_enabled = [:config_enabled] @credentials_path = [:credentials_path] || determine_credentials_path @parsed_credentials = {} load_credentials_file if loadable?(@credentials_path) if @config_enabled @config_path = [:config_path] || determine_config_path load_config_file if loadable?(@config_path) end end |
Instance Attribute Details
#config_path ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/aws-sdk-core/shared_config.rb', line 10 def config_path @config_path end |
#credentials_path ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'lib/aws-sdk-core/shared_config.rb', line 7 def credentials_path @credentials_path end |
#profile_name ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/aws-sdk-core/shared_config.rb', line 13 def profile_name @profile_name end |
Instance Method Details
#assume_role_credentials_from_config(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Attempts to assume a role from shared config or shared credentials file. Will always attempt first to assume a role from the shared credentials file, if present.
112 113 114 115 116 117 118 119 120 |
# File 'lib/aws-sdk-core/shared_config.rb', line 112 def assume_role_credentials_from_config(opts = {}) p = opts.delete(:profile) || @profile_name chain_config = opts.delete(:chain_config) credentials = assume_role_from_profile(@parsed_credentials, p, opts, chain_config) if @parsed_config credentials ||= assume_role_from_profile(@parsed_config, p, opts, chain_config) end credentials end |
#assume_role_web_identity_credentials_from_config(profile) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/aws-sdk-core/shared_config.rb', line 122 def assume_role_web_identity_credentials_from_config(profile) p = profile || @profile_name if @config_enabled && @parsed_config entry = @parsed_config.fetch(p, {}) if entry['web_identity_token_file'] && entry['role_arn'] AssumeRoleWebIdentityCredentials.new( role_arn: entry['role_arn'], web_identity_token_file: entry['web_identity_token_file'], role_session_name: entry['role_session_name'] ) else nil end else nil end end |
#config_enabled? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if use of the shared config file is enabled.
88 89 90 |
# File 'lib/aws-sdk-core/shared_config.rb', line 88 def config_enabled? @config_enabled ? true : false end |
#credentials(opts = {}) ⇒ Aws::Credentials
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sources static credentials from shared credential/config files.
99 100 101 102 103 104 105 106 107 |
# File 'lib/aws-sdk-core/shared_config.rb', line 99 def credentials(opts = {}) p = opts[:profile] || @profile_name validate_profile_exists(p) if credentials_present? if (credentials = credentials_from_shared(p, opts)) credentials elsif (credentials = credentials_from_config(p, opts)) credentials end end |
#credentials_process(profile) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
208 209 210 211 |
# File 'lib/aws-sdk-core/shared_config.rb', line 208 def credentials_process(profile) validate_profile_exists(profile) @parsed_config[profile]['credential_process'] end |
#csm_client_id(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/aws-sdk-core/shared_config.rb', line 228 def csm_client_id(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials value = @parsed_credentials.fetch(p, {})["csm_client_id"] end if @parsed_config value ||= @parsed_config.fetch(p, {})["csm_client_id"] end value else nil end end |
#csm_enabled(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/aws-sdk-core/shared_config.rb', line 213 def csm_enabled(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials value = @parsed_credentials.fetch(p, {})["csm_enabled"] end if @parsed_config value ||= @parsed_config.fetch(p, {})["csm_enabled"] end value else nil end end |
#csm_host(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/aws-sdk-core/shared_config.rb', line 258 def csm_host(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials value = @parsed_credentials.fetch(p, {})["csm_host"] end if @parsed_config value ||= @parsed_config.fetch(p, {})["csm_host"] end value else nil end end |
#csm_port(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/aws-sdk-core/shared_config.rb', line 243 def csm_port(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials value = @parsed_credentials.fetch(p, {})["csm_port"] end if @parsed_config value ||= @parsed_config.fetch(p, {})["csm_port"] end value else nil end end |
#endpoint_discovery(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
201 202 203 204 205 206 |
# File 'lib/aws-sdk-core/shared_config.rb', line 201 def endpoint_discovery(opts = {}) p = opts[:profile] || @profile_name if @config_enabled && @parsed_config @parsed_config.fetch(p, {})["endpoint_discovery_enabled"] end end |
#fresh(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/aws-sdk-core/shared_config.rb', line 61 def fresh( = {}) @profile_name = nil @credentials_path = nil @config_path = nil @parsed_credentials = {} @parsed_config = nil @config_enabled = [:config_enabled] ? true : false @profile_name = determine_profile() @credentials_path = [:credentials_path] || determine_credentials_path load_credentials_file if loadable?(@credentials_path) if @config_enabled @config_path = [:config_path] || determine_config_path load_config_file if loadable?(@config_path) end end |
#loadable?(path) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method does not indicate if the file found at #path will be parsable, only if it can be read.
Returns true if a credential file exists and has appropriate read permissions at #path.
82 83 84 |
# File 'lib/aws-sdk-core/shared_config.rb', line 82 def loadable?(path) !path.nil? && File.exist?(path) && File.readable?(path) end |
#region(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/aws-sdk-core/shared_config.rb', line 141 def region(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials region = @parsed_credentials.fetch(p, {})["region"] end if @parsed_config region ||= @parsed_config.fetch(p, {})["region"] end region else nil end end |
#s3_us_east_1_regional_endpoint(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/aws-sdk-core/shared_config.rb', line 171 def s3_us_east_1_regional_endpoint(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials mode = @parsed_credentials.fetch(p, {})["s3_us_east_1_regional_endpoint"] end if @parsed_config mode ||= @parsed_config.fetch(p, {})["s3_us_east_1_regional_endpoint"] end mode else nil end end |
#s3_use_arn_region(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/aws-sdk-core/shared_config.rb', line 186 def s3_use_arn_region(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials value = @parsed_credentials.fetch(p, {})["s3_use_arn_region"] end if @parsed_config value ||= @parsed_config.fetch(p, {})["s3_use_arn_region"] end value else nil end end |
#sts_regional_endpoints(opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/aws-sdk-core/shared_config.rb', line 156 def sts_regional_endpoints(opts = {}) p = opts[:profile] || @profile_name if @config_enabled if @parsed_credentials mode = @parsed_credentials.fetch(p, {})["sts_regional_endpoints"] end if @parsed_config mode ||= @parsed_config.fetch(p, {})["sts_regional_endpoints"] end mode else nil end end |