-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
CognitoListUserPools.go
47 lines (38 loc) · 1.21 KB
/
CognitoListUserPools.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[cognito.go.list_user_pools]
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider"
"fmt"
"os"
)
func main() {
// Initialize a session that the SDK will use to load configuration,
// credentials, and region from the shared config file. (~/.aws/config).
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
// Create Cognito client
svc := cognitoidentityprovider.New(sess)
max := int64(10)
result, err := svc.ListUserPools(
&cognitoidentityprovider.ListUserPoolsInput{
MaxResults: &max,
}) // .ListBuckets(nil)
if err != nil {
fmt.Println("Could not list user pools")
os.Exit(1)
}
fmt.Println("User pools:")
fmt.Println("")
for _, pool := range result.UserPools {
fmt.Println("Name: " + aws.StringValue(pool.Name))
fmt.Println("ID: " + aws.StringValue(pool.Id))
fmt.Println("Created: " + aws.TimeValue(pool.CreationDate).String())
fmt.Println("")
}
}
// snippet-end:[cognito.go.list_user_pools]