@@ -90,6 +90,9 @@ type Plugin struct {
9090 PathStyle bool
9191 // Dry run without uploading/
9292 DryRun bool
93+
94+ // set externalID for assume role
95+ ExternalID string
9396}
9497
9598// Exec runs the plugin
@@ -108,7 +111,7 @@ func (p *Plugin) Exec() error {
108111 if p .Key != "" && p .Secret != "" {
109112 conf .Credentials = credentials .NewStaticCredentials (p .Key , p .Secret , "" )
110113 } else if p .AssumeRole != "" {
111- conf .Credentials = assumeRole (p .AssumeRole , p .AssumeRoleSessionName )
114+ conf .Credentials = assumeRole (p .AssumeRole , p .AssumeRoleSessionName , p . ExternalID )
112115 } else {
113116 log .Warn ("AWS Key and/or Secret not provided (falling back to ec2 instance profile)" )
114117 }
@@ -287,7 +290,7 @@ func matchExtension(match string, stringMap map[string]string) string {
287290 return ""
288291}
289292
290- func assumeRole (roleArn , roleSessionName string ) * credentials.Credentials {
293+ func assumeRole (roleArn , roleSessionName , externalID string ) * credentials.Credentials {
291294 sess , _ := session .NewSession ()
292295 client := sts .New (sess )
293296 duration := time .Hour * 1
@@ -298,6 +301,10 @@ func assumeRole(roleArn, roleSessionName string) *credentials.Credentials {
298301 RoleSessionName : roleSessionName ,
299302 }
300303
304+ if externalID != "" {
305+ stsProvider .ExternalID = & externalID
306+ }
307+
301308 return credentials .NewCredentials (stsProvider )
302309}
303310
@@ -318,17 +325,17 @@ func isDir(source string, matches []string) bool {
318325 if err != nil {
319326 return true // should never happen
320327 }
321- if ( stat .IsDir () ) {
328+ if stat .IsDir () {
322329 count := 0
323330 for _ , match := range matches {
324331 if strings .HasPrefix (match , source ) {
325- count ++ ;
332+ count ++
326333 }
327334 }
328335 if count <= 1 {
329336 log .Warnf ("Skipping '%s' since it is a directory. Please use correct glob expression if this is unexpected." , source )
330337 }
331- return true ;
338+ return true
332339 }
333340 return false
334341}
0 commit comments