考虑一下这个例子:
aws cognito-idp admin-update-user-attributes --user-pool-id myUserPollId
--username myUser
--user-attributes [{"Name": "custom:roles","Value": "ROLE1,ROLE2"}] --region us-east-1
这让我错误:
Invalid JSON:
[{Name:
答案 0 :(得分:3)
您始终可以尝试使用速记语法:
--user-attributes Name="custom:roles",Value="ROLE1,ROLE2"
如果您真的想使用JSON语法,请尝试以下方法:
--user-attributes '[{"Name" : "custom:roles","Value" : "ROLE1,ROLE2"}]'
答案 1 :(得分:1)
--user-attributes '[{"Name": "phone_number", "Value": "+123434532"},
{"Name": "name", "Value":"name_your"}]'
答案 2 :(得分:0)
万一有人再次陷入同一问题,下面是通过 aws cli和json 文件更新用户属性的测试步骤。
步骤0:设置 AWS CLI (如果尚未安装)。 Mac用户可以运行:
brew install awscli
步骤1:随身携带一个有效的json,保存在文件中。有效格式的json示例:
{
"UserAttributes": [{
"Name": "custom:additional-attribute1",
"Value": "Value for additional attribute 1"
},
{
"Name": "custom:additional-attribute2",
"Value": "Value for additional attribute 2"
}
]
}
步骤2:在控制台中运行以下命令:
aws cognito-idp admin-update-user-attributes --user-pool-id XX-XXXX-X_XXXXXXXXX --username XXXXX@XXXXX.com --cli-input-json file:///Users/YOUR_PATH_TO_THE_FILE/user-attributes.json
参数:
--user-pool-id :: Your user pool ID.
--username :: The user you want to udpate.
--cli-input-json :: This is the command that loads json file and parses it.
就是这样。如果您的json有效且aws cli授权,则应立即更新给定的用户记录。