diff --git a/aws/accountid/account_id.go b/aws/accountid/account_id.go index a1736007d37..6a695afbebb 100644 --- a/aws/accountid/account_id.go +++ b/aws/accountid/account_id.go @@ -8,6 +8,7 @@ import ( "github.com/aws/smithy-go/auth" ) +// AccountID retrieves the accountID from identity or ignores that depending on accountID endpoint mode func AccountID(identity auth.Identity, mode accountidmode.AIDMode) *string { if ca, ok := identity.(*smithy.CredentialsAdapter); ok && (mode == accountidmode.Preferred || mode == accountidmode.Required) { return aws.String(ca.Credentials.AccountID) @@ -16,6 +17,8 @@ func AccountID(identity auth.Identity, mode accountidmode.AIDMode) *string { return nil } +// CheckAccountID checks accountID mode in case the required accountID misses or +// accountID endpoint mode is configured with invalid value func CheckAccountID(identity auth.Identity, mode accountidmode.AIDMode) error { switch mode { case "": diff --git a/aws/accountid/mode/mode.go b/aws/accountid/mode/mode.go index 8f3ff2d2900..2d931954f1c 100644 --- a/aws/accountid/mode/mode.go +++ b/aws/accountid/mode/mode.go @@ -5,12 +5,14 @@ import "fmt" // AIDMode switches on/off the account ID based endpoint routing type AIDMode string +// enums of valid AIDMode const ( Preferred AIDMode = "preferred" Required AIDMode = "required" Disabled AIDMode = "disabled" ) +// SetFromString converts config string to corresponding AIDMode or reports error if the value is not enumerated func (mode *AIDMode) SetFromString(s string) error { switch { case s == "preferred":