Package: session
Constants
-
Value:
"SharedConfigErr" -
const ErrCodeLoadCustomCABundle = readonly
ErrCodeLoadCustomCABundle error code for unable to load custom CA bundle.
-
Value:
"LoadCustomCABundleError" -
const ErrCodeLoadClientTLSCert = readonly
ErrCodeLoadClientTLSCert error code for unable to load client TLS certificate or key
-
Value:
"LoadClientTLSCertError" -
Value:
iota -
const EnvProviderName = readonly
EnvProviderName provides a name of the provider when config is loaded from environment.
-
Value:
"EnvConfigCredentials" -
Value:
`default`
Variables
-
Value:
awserr.New(ErrCodeSharedConfig, "only one credential type may be specified per profile: source profile, credential source, credential process, web identity token", nil) -
Value:
awserr.New(ErrCodeSharedConfig, "EcsContainer was specified as the credential_source, but 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' was not set", nil) -
Value:
awserr.New(ErrCodeSharedConfig, "credential source values must be EcsContainer, Ec2InstanceMetadata, or Environment", nil)
Type Summary collapse
-
Options
struct
Options provides the means to control how a Session is created and what configuration values will be loaded.
-
Session
struct
A Session provides a central location to create service clients from and store configurations and request handlers for those services.
-
SharedConfigAssumeRoleError
struct
SharedConfigAssumeRoleError is an error for the shared config when the profile contains assume role information, but that information is invalid or not complete.
-
SharedConfigLoadError
struct
SharedConfigLoadError is an error for the shared config file failed to load.
-
SharedConfigProfileNotExistsError
struct
SharedConfigProfileNotExistsError is an error for the shared config when the profile was not find in the config file.
Function Summary collapse
-
func NewSession(cfgs ...*aws.Config) (*Session, error)
NewSession returns a new Session created from SDK defaults, config files, environment, and user provided config files.
-
func NewSessionWithOptions(opts Options) (*Session, error)
NewSessionWithOptions returns a new Session created from SDK defaults, config files, environment, and user provided config files.
Type Details
Options struct
Options provides the means to control how a Session is created and what configuration values will be loaded.
Function Details
func NewSession(cfgs ...*aws.Config) (*Session, error)
NewSession returns a new Session created from SDK defaults, config files, environment, and user provided config files. Once the Session is created it can be mutated to modify the Config or Handlers. The Session is safe to be read concurrently, but it should not be written to concurrently.
If the AWS_SDK_LOAD_CONFIG environment variable is set to a truthy value the shared config file (~/.aws/config) will also be loaded in addition to the shared credentials file (~/.aws/credentials). Values set in both the shared config, and shared credentials will be taken from the shared credentials file. Enabling the Shared Config will also allow the Session to be built with retrieving credentials with AssumeRole set in the config.
See the NewSessionWithOptions func for information on how to override or control through code how the Session will be created, such as specifying the config profile, and controlling if shared config is enabled or not.
100 101 102 103 104 105 |
// File 'aws/session/session.go', line 100
|
func NewSessionWithOptions(opts Options) (*Session, error)
NewSessionWithOptions returns a new Session created from SDK defaults, config files, environment, and user provided config files. This func uses the Options values to configure how the Session is created.
If the AWS_SDK_LOAD_CONFIG environment variable is set to a truthy value the shared config file (~/.aws/config) will also be loaded in addition to the shared credentials file (~/.aws/credentials). Values set in both the shared config, and shared credentials will be taken from the shared credentials file. Enabling the Shared Config will also allow the Session to be built with retrieving credentials with AssumeRole set in the config.
// Equivalent to session.New
sess := session.Must(session.NewSessionWithOptions(session.Options{}))
// Specify profile to load for the session's config
sess := session.Must(session.NewSessionWithOptions(session.Options{
Profile: "profile_name",
}))
// Specify profile for config and region for requests
sess := session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{Region: aws.String("us-east-1")},
Profile: "profile_name",
}))
// Force enable Shared Config support
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
// File 'aws/session/session.go', line 267
|