我正在使用 boto3 創(chuàng)建一個 IAM 用戶,等到 IAM 用戶被創(chuàng)建,然后更新該用戶的登錄配置文件。我創(chuàng)建用戶的python代碼工作正常,用戶創(chuàng)建成功。IAM 最終是一致的,所以我知道我需要等待用戶被創(chuàng)建,然后我才能用它做任何其他事情,我為此使用了一個服務(wù)員。但是當(dāng)我嘗試更新登錄配置文件時,它出錯說用戶還不存在。所以基本上服務(wù)員并沒有像它應(yīng)該的那樣等待。有誰知道我在這里做錯了什么?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)預(yù)期結(jié)果:服務(wù)員應(yīng)該等待 IAM 用戶存在足夠長的時間,然后更新登錄配置文件將按預(yù)期工作。實際結(jié)果: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.
Boto3 IAM 服務(wù)員不等待
拉風(fēng)的咖菲貓
2021-12-21 10:52:02