forked from kreuzwerker/awsu
/
profile.go
33 lines (27 loc) · 941 Bytes
/
profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package config
import (
"github.com/aws/aws-sdk-go/aws/credentials"
)
// Profile is a long- or short-time credential profile managed in a shared config
type Profile struct {
AccessKeyID string `ini:"aws_access_key_id"`
ExternalID string `ini:"external_id"`
MFASerial string `ini:"mfa_serial"`
Name string
Region string `ini:"region"`
RoleARN string `ini:"role_arn"`
SecretAccessKey string `ini:"aws_secret_access_key"`
SourceProfile string `ini:"source_profile"`
}
// IsLongTerm identifies a profile that does not assume a role using a source profile
func (p *Profile) IsLongTerm() bool {
return p.RoleARN == ""
}
// Value returns the credentials associated with the profile (if any) - only long
// term profiles have credentials
func (p *Profile) Value() credentials.Value {
return credentials.Value{
AccessKeyID: p.AccessKeyID,
SecretAccessKey: p.SecretAccessKey,
}
}