Struct: credentials.EnvProvider

import "../ibm-cos-sdk-go/aws/credentials"

Overview

A EnvProvider retrieves credentials from the environment variables of the running process. Environment credentials never expire.

Environment variables used:

  • Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY

  • Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY

Implemented Interfaces

s3crypto.Cipher, credentials.Provider, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom

Method Summary collapse

Method Details

func (e *EnvProvider) IsExpired() bool

IsExpired returns if the credentials have been retrieved.



71
72
73
// File 'aws/credentials/env_provider.go', line 71

func (e *EnvProvider) IsExpired() bool { return !e.retrieved }

func (e *EnvProvider) Retrieve() (Value, error)

Retrieve retrieves the keys from the environment.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// File 'aws/credentials/env_provider.go', line 40

func (e *EnvProvider) Retrieve() (Value, error) { e.retrieved = false id := os.Getenv("AWS_ACCESS_KEY_ID") if id == "" { id = os.Getenv("AWS_ACCESS_KEY") } secret := os.Getenv("AWS_SECRET_ACCESS_KEY") if secret == "" { secret = os.Getenv("AWS_SECRET_KEY") } if id == "" { return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound } if secret == "" { return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound } e.retrieved = true return Value{ AccessKeyID: id, SecretAccessKey: secret, SessionToken: os.Getenv("AWS_SESSION_TOKEN"), ProviderName: EnvProviderName, }, nil }