我正在尝试运行官方文档中所示的admin-create-user cli命令,但它似乎无法正常运行。
尽管命令中存在所有属性创建事件,但我并未获得所有属性创建事件。我总是只得到命令中键入的最后一个属性。
我做错什么了吗?有什么解决办法吗?aws cognito-idp admin-create-user --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --user-attributes=Name=email,Value=kermit2@somewhere.com,Name=phone_number,Value="+15555551212" --message-action SUPPRESS
我得到了
{
"User": {
"Username": "diego@example.com",
"Enabled": true,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"UserCreateDate": 1566470568.864,
"UserLastModifiedDate": 1566470568.864,
"Attributes": [
{
"Name": "sub",
"Value": "5dac8ce5-2997-4185-b862-86cf15aede77"
},
{
"Name": "phone_number",
"Value": "+15555551212"
}
]
}
}
代替
{
"User": {
"Username": "7325c1de-b05b-4f84-b321-9adc6e61f4a2",
"Enabled": true,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"UserCreateDate": 1548099495.428,
"UserLastModifiedDate": 1548099495.428,
"Attributes": [
{
"Name": "sub",
"Value": "7325c1de-b05b-4f84-b321-9adc6e61f4a2"
},
{
"Name": "phone_number",
"Value": "+15555551212"
},
{
"Name": "email",
"Value": "diego@example.com"
}
]
}
}
答案 0 :(得分:2)
文档here中所引用的速记符号确实确实在产生您收到的结果。
解决此问题的快速方法是更改为user-attributes
选项使用JSON格式。如果您将user-attributes
选项修改为使用JSON,则命令将如下所示:
aws cognito-idp admin-create-user --user-pool-id us-west-2_aaaaaaaaa --username a567 --user-attributes '[{"Name": "email","Value": "kermit2@somewhere.com"},{"Name": "phone_number","Value": "+15555551212"}]' --message-action SUPPRESS
执行时会产生以下输出:
{
"User": {
"Username": "a567",
"Enabled": true,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"UserCreateDate": 1566489693.408,
"UserLastModifiedDate": 1566489693.408,
"Attributes": [
{
"Name": "sub",
"Value": "f6ff3e05-5f15-4a53-a45f-52e939b941fd"
},
{
"Name": "phone_number",
"Value": "+15555551212"
},
{
"Name": "email",
"Value": "kermit2@somewhere.com"
}
]
}
}