module AWS::Profiles

The shared configuration files the SDKs and the CLI read: ~/.aws/credentials (AWS_SHARED_CREDENTIALS_FILE), whose sections are profile names, and ~/.aws/config (AWS_CONFIG_FILE), whose sections are [default] and [profile name]. A profile's settings are both files' merged, the credentials file's winning.

AWS::Profiles.parse("[default]\nregion = eu-west-1\n# a comment\n", false)
# => {"default" => {"region" => "eu-west-1"}}
AWS::Profiles.parse("[profile dev]\nregion=us-east-2\n", true)
# => {"dev" => {"region" => "us-east-2"}}

/home/runner/work/aws/aws/src/profiles.qz:13

Class methods

def self.settings(name: String, env: Hash[String, String] = …) -> Hash[String, String]?

The settings of profile name, nil when neither file has it (env gives the files' paths and HOME). Raises CredentialsError for a file that cannot be read.

/home/runner/work/aws/aws/src/profiles.qz:17

def self.region(name: String? = …, env: Hash[String, String] = …) -> String?

The region of profile name (AWS_PROFILE, else default), nil when it has none. Raises CredentialsError as .settings does.

/home/runner/work/aws/aws/src/profiles.qz:26

def self.parse(text: String, config: Bool) -> Hash[String, Hash[String, String]]

The profiles of an INI text: [section] lines (a comment may follow them), name = value lines under them (names lowercased, values trimmed), # and ; comment lines. A line indented deeper than the setting above it continues it or is one of its sub-settings (s3 = then addressing_style = path): not a setting of the profile, as configparser reads it. In a config file (config), [profile name] is profile name and a section of another form but [default] is not a profile.

/home/runner/work/aws/aws/src/profiles.qz:65