我正在尝试重命名 AWS IAM Identity Center(以前称为 AWS Single Sign-On)中现有用户的用户名。 我知道无法在 AWS 控制台中更改用户名,因为该字段不可编辑,但文档表明可以使用 CLI(或 API)。我已经通过 CLI 尝试了以下操作,但没有取得太大成功:
aws identitystore update-user --cli-input-json file://input.json
input.json
{
"IdentityStoreId": [id],
"UserId": [uid],
"Operations": [
{
"AttributePath": "UserName",
"AttributeValue": "new-username"
}
]
}
返回以下错误信息:
调用UpdateUser时发生错误(ValidationException) 操作:属性路径更新:不支持用户名
我使用以下方式描述了现有用户:
aws identitystore describe-user --identity-store-id [id] --user-id [uid]
返回:
{
"UserName": "existing-username",
"UserId": [uid],
...
}
据我所知,属性路径是正确的,所以我不确定为什么这不起作用。我找不到任何有关此不受支持的信息。
经过一番尝试后,我成功找到了解决方案,但文档非常糟糕。
以下请求成功,属性名称需要采用驼峰式命名法
userName
才能生效。
input.json
{
"IdentityStoreId": [id],
"UserId": [uid],
"Operations": [
{
"AttributePath": "userName",
"AttributeValue": "new-username"
}
]
}
如问题中所述,
describe-user
将属性返回为UserName
:
{
"UserName": "existing-username",
"UserId": [uid],
...
}
在 AWS 控制台中,属性为
Username
:
在 API 文档 (https://docs.aws.amazon.com/singlesignon/latest/IdentityStoreAPIReference/API_User.html) 中,属性为
UserName
: