-
-
Save lolgolflol/27e73a46d10fa94e943a37493a45aff3 to your computer and use it in GitHub Desktop.
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 ( | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider" | |
"github.com/aws/aws-sdk-go/service/dynamodb" | |
) | |
func main() { | |
sess := session.New() | |
client := dynamodb.New(sess) | |
output, err := client.Query(&dynamodb.QueryInput{ | |
TableName: aws.String("database-User-RLLBS793H71J"), | |
KeyConditionExpression: aws.String("data_scope = :ds"), | |
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{ | |
":ds": &dynamodb.AttributeValue{ | |
S: aws.String("root"), | |
}, | |
}, | |
IndexName: aws.String("data_scope-index"), | |
}) | |
if err != nil { | |
panic(err.Error()) | |
} | |
for _, item := range output.Items { | |
if item["username"] != nil { | |
// fmt.Println(*item["username"].S) | |
congnitoProvider := cognitoidentityprovider.New(sess) | |
inputQuery := cognitoidentityprovider.AdminGetUserInput{ | |
UserPoolId: aws.String("ap-southeast-1_DahHeXkdy"), | |
Username: item["username"].S, | |
} | |
congnitoOutput, err := congnitoProvider.AdminGetUser(&inputQuery) | |
if err != nil { | |
// panic(err.Error()) | |
fmt.Printf("%s : %s \n", *item["username"].S, err.Error()) | |
} | |
for _, item2 := range congnitoOutput.UserAttributes { | |
if *item2.Name == "custom:registered_from" { | |
fmt.Println(*item["username"].S) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment