@@ -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 }
@@ -290,7 +293,7 @@ func matchExtension(match string, stringMap map[string]string) string {
290293 return ""
291294}
292295
293- func assumeRole (roleArn , roleSessionName string ) * credentials.Credentials {
296+ func assumeRole (roleArn , roleSessionName , externalID string ) * credentials.Credentials {
294297 sess , _ := session .NewSession ()
295298 client := sts .New (sess )
296299 duration := time .Hour * 1
@@ -301,6 +304,10 @@ func assumeRole(roleArn, roleSessionName string) *credentials.Credentials {
301304 RoleSessionName : roleSessionName ,
302305 }
303306
307+ if externalID != "" {
308+ stsProvider .ExternalID = & externalID
309+ }
310+
304311 return credentials .NewCredentials (stsProvider )
305312}
306313
@@ -321,17 +328,17 @@ func isDir(source string, matches []string) bool {
321328 if err != nil {
322329 return true // should never happen
323330 }
324- if ( stat .IsDir () ) {
331+ if stat .IsDir () {
325332 count := 0
326333 for _ , match := range matches {
327334 if strings .HasPrefix (match , source ) {
328- count ++ ;
335+ count ++
329336 }
330337 }
331338 if count <= 1 {
332339 log .Warnf ("Skipping '%s' since it is a directory. Please use correct glob expression if this is unexpected." , source )
333340 }
334- return true ;
341+ return true
335342 }
336343 return false
337344}
0 commit comments