Created
September 2, 2022 09:34
-
-
Save takumin/e990ca26aee9800e8578bdb811644f46 to your computer and use it in GitHub Desktop.
Check AWS SSO ListUsers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module github.com/takumin/sso-users | |
go 1.19 | |
require ( | |
github.com/aws/aws-sdk-go-v2 v1.16.13 | |
github.com/aws/aws-sdk-go-v2/config v1.17.4 | |
github.com/aws/aws-sdk-go-v2/service/identitystore v1.15.0 | |
) | |
require ( | |
github.com/aws/aws-sdk-go-v2/credentials v1.12.17 // indirect | |
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.14 // indirect | |
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.20 // indirect | |
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.14 // indirect | |
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.21 // indirect | |
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.14 // indirect | |
github.com/aws/aws-sdk-go-v2/service/sso v1.11.20 // indirect | |
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.2 // indirect | |
github.com/aws/aws-sdk-go-v2/service/sts v1.16.16 // indirect | |
github.com/aws/smithy-go v1.13.1 // indirect | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github.com/aws/aws-sdk-go-v2 v1.16.13 h1:HgF7OX2q0gSZtcXoo9DMEA8A2Qk/GCxmWyM0RI7Yz2Y= | |
github.com/aws/aws-sdk-go-v2 v1.16.13/go.mod h1:xSyvSnzh0KLs5H4HJGeIEsNYemUWdNIl0b/rP6SIsLU= | |
github.com/aws/aws-sdk-go-v2/config v1.17.4 h1:9HY1wbShqObySCHP2Z07blfrSWVX+nVxCZmUuLZKcG8= | |
github.com/aws/aws-sdk-go-v2/config v1.17.4/go.mod h1:ul+ru+huVpfduF9XRmGUq82T8T3K+nIFQuF6F+L+548= | |
github.com/aws/aws-sdk-go-v2/credentials v1.12.17 h1:htUjIJOQcvIUR0jC4eLkdis1DfaLL4EUbIKUFqh2WFA= | |
github.com/aws/aws-sdk-go-v2/credentials v1.12.17/go.mod h1:jd1mvJulXY7ccHvcSiJceYhv06yWIIRkJnwWEA4IX+g= | |
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.14 h1:NZwZFtxXGOEIiCd8jWN55lexakug543CaO68bTpoLwg= | |
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.14/go.mod h1:5CU57SyF5jZLSIw4OOll0PG83ThXwNdkRFOc0EltD/0= | |
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.20 h1:Rk8eqZSdFovt8Id+O+i2qT0c3CY13DPn2SfGOEVlxNs= | |
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.20/go.mod h1:gdZ5gRUaxThXIZyZQ8MTtgYBk2jbHgp05BO3GcD9Cwc= | |
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.14 h1:6Yxuq9yrkoLYab5JXqJnto9tdRuIcYVdR+eiKjsJYWU= | |
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.14/go.mod h1:GEV9jaDPIgayiU+uevxwozcvUOjc+P4aHE2BeSjm2vE= | |
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.21 h1:lpwSbLKYTuABo6SyUoC25xAmfO3/TehGS2SmD1EtOL0= | |
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.21/go.mod h1:Q0pktZjvRZk77TBto6yAvUAi7fcse1bdcMctBDVGgBw= | |
github.com/aws/aws-sdk-go-v2/service/identitystore v1.15.0 h1:RkSEzzGoabfnnVXF9Mon9+/KYYVw2hLjK1i47ka/Tyg= | |
github.com/aws/aws-sdk-go-v2/service/identitystore v1.15.0/go.mod h1:7dp7wVJ+ldmxHAD1Zo6Q65duUXCtNNoFk10Eu8uSCco= | |
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.14 h1:c5hJNN2DkK1gAytcKp7LkiKNDJeevFSboPezEHAM4Ro= | |
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.14/go.mod h1:8qOLjqMzY/S1kh3myDXA1yxK5eD4uN8aOJgKpgvc4OM= | |
github.com/aws/aws-sdk-go-v2/service/sso v1.11.20 h1:3raP0UC9rvRyY4/cc4o4F3jTrNo94AYiarNUGNnq6dU= | |
github.com/aws/aws-sdk-go-v2/service/sso v1.11.20/go.mod h1:hPsROgDdgY/NQ1gPt7VJWG0GjSnalDC0DkkMfGEw2gc= | |
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.2 h1:/SYpdjjAtraymql+/r719OgjxezdanAQiLb/NMxDb04= | |
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.2/go.mod h1:5cxfDYtY2mDOlmesy4yycb6lwyy1U/iAUOHKhQLKw/E= | |
github.com/aws/aws-sdk-go-v2/service/sts v1.16.16 h1:otZvq9r+xjPL7qU/luX2QdBamiN+oSZURRi4sAKymO8= | |
github.com/aws/aws-sdk-go-v2/service/sts v1.16.16/go.mod h1:Y9iBgT1w2vHtYzJEkwD6FqILjDSsvbxcW/+wIYxyse4= | |
github.com/aws/smithy-go v1.13.1 h1:q09BdpUiaqpothcv393ACfWJJHzlzjB5HaNL1XHKmoQ= | |
github.com/aws/smithy-go v1.13.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= | |
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | |
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= | |
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | |
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= | |
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= | |
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | |
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | |
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"flag" | |
"log" | |
"github.com/aws/aws-sdk-go-v2/aws" | |
"github.com/aws/aws-sdk-go-v2/config" | |
"github.com/aws/aws-sdk-go-v2/service/identitystore" | |
) | |
var ( | |
identityStoreId string | |
) | |
func main() { | |
flag.StringVar(&identityStoreId, "identityStoreId", "", "AWS SSO Identity Store ID") | |
flag.Parse() | |
if identityStoreId == "" { | |
log.Fatalln("required -identityStoreId arguments") | |
} | |
cfg, err := config.LoadDefaultConfig(context.TODO()) | |
if err != nil { | |
log.Fatal(err) | |
} | |
client := identitystore.NewFromConfig(cfg) | |
params := &identitystore.ListUsersInput{ | |
IdentityStoreId: aws.String(identityStoreId), | |
MaxResults: 50, | |
} | |
paginator := identitystore.NewListUsersPaginator(client, params, func(o *identitystore.ListUsersPaginatorOptions) { | |
o.Limit = 50 | |
}) | |
for paginator.HasMorePages() { | |
output, err := paginator.NextPage(context.TODO()) | |
if err != nil { | |
log.Fatal(err) | |
} | |
for _, v := range output.Users { | |
log.Println(aws.ToString(v.UserName)) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APPNAME := $(shell basename $(CURDIR)) | |
VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null) | |
REVISION := $(shell git rev-parse HEAD 2>/dev/null) | |
ifeq ($(VERSION),) | |
VERSION := dev | |
endif | |
ifeq ($(REVISION),) | |
REVISION := unknown | |
endif | |
LDFLAGS_APPNAME := -X "main.AppName=$(APPNAME)" | |
LDFLAGS_VERSION := -X "main.Version=$(VERSION)" | |
LDFLAGS_REVISION := -X "main.Revision=$(REVISION)" | |
LDFLAGS := -s -w -buildid= $(LDFLAGS_APPNAME) $(LDFLAGS_VERSION) $(LDFLAGS_REVISION) -extldflags -static | |
BUILDFLAGS := -trimpath -ldflags '$(LDFLAGS)' | |
.PHONY: all | |
all: clean lint vet build | |
.PHONY: lint | |
lint: | |
CGO_ENABLED=0 staticcheck ./... | |
.PHONY: vet | |
vet: | |
CGO_ENABLED=0 go vet ./... | |
.PHONY: build | |
build: bin/$(BINNAME) | |
bin/$(BINNAME): $(SRCS) | |
CGO_ENABLED=0 go build $(BUILDFLAGS) -o $@ | |
.PHONY: install | |
install: build | |
CGO_ENABLED=0 go install $(BUILDFLAGS) | |
.PHONY: clean | |
clean: | |
rm -rf bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment