Skip to content

Commit

Permalink
iam-sync-users/iam-public-ssh-keys: Use common.OpenSession
Browse files Browse the repository at this point in the history
  • Loading branch information
hamstah committed Jul 18, 2019
1 parent 7e66c1b commit 115644d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions iam/public-ssh-keys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/hamstah/awstools/common"
Expand All @@ -25,8 +24,7 @@ func main() {
kingpin.CommandLine.Help = "Return public SSH keys for an IAM user."
flags := common.HandleFlags()

session := session.Must(session.NewSession())
conf := common.AssumeRoleConfig(flags, session)
session, conf := common.OpenSession(flags)

iamClient := iam.New(session, conf)

Expand Down
8 changes: 3 additions & 5 deletions iam/sync-users/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/hamstah/awstools/common"
log "github.com/sirupsen/logrus"
Expand All @@ -40,8 +39,7 @@ func main() {
flags := common.HandleFlags()
common.FatalOnError(ensureCanCreateUser())

session := session.Must(session.NewSession())
conf := common.AssumeRoleConfig(flags, session)
session, conf := common.OpenSession(flags)

iamClient := iam.New(session, conf)

Expand Down Expand Up @@ -199,8 +197,8 @@ func syncUserGroups(iamUser *IAMUser) error {
groupsStr := strings.Join(iamUser.Groups, ",")
log.WithFields(log.Fields{
"username": iamUser.Username,
"groups": groupsStr,
}).Info("Setting user groups")
"groups": groupsStr,
}).Info("Setting user groups")
return RunCommand("/usr/sbin/usermod", "-G", groupsStr, iamUser.Username)
}

Expand Down

0 comments on commit 115644d

Please sign in to comment.