I have a lambda trigger in my user pool (post confirmation lambda trigger), which calls the code below:
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session", err.Error())
}
svc := cognitoidentityprovider.New(sess)
params := &cognitoidentityprovider.AdminUpdateUserAttributesInput{
UserAttributes: []*cognitoidentityprovider.AttributeType{
{
Name: aws.String("custom:onboarding"),
Value: aws.Int(0),
},
},
UserPoolId: aws.String("xxxxx"),
Username: aws.String("xxxxx"),
}
resp, err := svc.AdminUpdateUserAttributes(params)
if err != nil {
fmt.Println("resp error: ", err.Error())
}
fmt.Println(resp)
Im receiving the following error:
.\main.go:36:5: cannot use "github.com/aws/aws-sdk-go-v2/aws".Int(0) (type *int) as type *string in field value
The value needs to be an integer, as the custom attribute is set as a number in cognito.
What am I missing here? Or is this not the right method?
Thanks in advance
I have found the answer. As isavinof said, the value has a string type, which wasn't working initially, however, it turned out to be a permissions error ( AccessDeniedException ).
To fix the problem, I followed this answer: https://stackoverflow.com/a/67678111/1898662
I. CREATING THE POLICY (FOR PERMISSION)
etc.) In this case, it was write -> AdminUpdateUserAttributesInput
II. ADDING THE POLICY TO THE USER :