我正在使用 boto3 創建一個 IAM 用戶,等到 IAM 用戶被創建,然后更新該用戶的登錄配置文件。我創建用戶的python代碼工作正常,用戶創建成功。IAM 最終是一致的,所以我知道我需要等待用戶被創建,然后我才能用它做任何其他事情,我為此使用了一個服務員。但是當我嘗試更新登錄配置文件時,它出錯說用戶還不存在。所以基本上服務員并沒有像它應該的那樣等待。有誰知道我在這里做錯了什么?import boto3password = 'not_the_real_password'client = boto3.client('iam')# Create the userresponse = client.create_user( UserName='someuser')# Creating the user works fine. But IAM is eventually consistent, so we have# to wait for the user to be created before we can do anything with it.waiter = client.get_waiter('user_exists')waiter.wait(UserName='someuser')# If the waiter worked correctly, then it should have waited for the user# to be created before updating the login profile.response = client.update_login_profile( UserName='someuser', Password=password, PasswordResetRequired=True)預期結果:服務員應該等待 IAM 用戶存在足夠長的時間,然后更新登錄配置文件將按預期工作。實際結果:Traceback (most recent call last): File "add_user.py", line 20, in <module> PasswordResetRequired=True File "/home/myuser/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call return self._make_api_call(operation_name, kwargs) File "/home/myuser/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call raise error_class(parsed_response, operation_name)botocore.errorfactory.NoSuchEntityException: An error occurred (NoSuchEntity) when calling the UpdateLoginProfile operation: Login Profile for User someuser cannot be found.
1 回答

蠱毒傳說
TA貢獻1895條經驗 獲得超3個贊
錯誤說:
找不到用戶 someuser 的登錄配置文件。
在登錄個人資料是單獨的用戶。它需要專門創建。
更改update_login_profile()
成create_login_profile()
。
添加回答
舉報
0/150
提交
取消