Boto3 IAM服务员不在等待 [英] Boto3 IAM waiter isn't waiting

查看:314
本文介绍了Boto3 IAM服务员不在等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用boto3创建IAM用户,等待创建IAM用户,然后更新该用户的登录配置文件.我创建用户的python代码工作正常,并且用户创建成功.IAM最终是一致的,因此我知道我需要等待创建用户之后才能对其进行任何其他操作,并且我正在为此目的使用侍者.但是当我尝试更新登录配置文件时,它错误地指出用户还不存在.

I'm using boto3 to create an IAM user, wait until the IAM user is created, then update the login profile of that user. My python code to create the user works fine, and the user is created successfully. IAM is eventually consistent, so I know that I need to wait for the user to be created before I can do anything else with it, and I am using a waiter for that purpose. But when I try to update the login profile, it errors out saying that the user doesn't exist yet.

所以基本上服务员没有像应该的那样等待.

So basically the waiter isn't waiting like it should.

有人知道我在做什么错吗?

Anyone know what I'm doing wrong here?

import boto3

password = 'not_the_real_password'

client = boto3.client('iam')

# Create the user
response = 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用户存在,然后更新登录配置文件即可按预期工作.

Expected result: the waiter should wait long enough that the IAM user exists, and then updating the login profile would work as expected.

实际结果:

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.

推荐答案

错误提示:

找不到用户someuser的登录配置文件.

Login Profile for User someuser cannot be found.

登录配置文件用户是分开的.它需要专门创建.

The Login Profile is separate to the User. It needs to be specifically created.

update_login_profile()更改为 create_login_profile().

这篇关于Boto3 IAM服务员不在等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆