我有一个不同类型的用户群(user_type 属性将定义类型)。我想在确认后禁用某些类型的用户。即流程:用户注册--> 用户收到带有代码的确认电子邮件--> 用户输入代码--> 后确认触发器被调用。
这是我的确认后触发器 lambda:
import logging
import boto3
logger = logging.getLogger()
logger.setLevel(logging.INFO)
cognito_client = boto3.client('cognito-idp')
def lambda_handler(event, context):
user_type = event['request']['userAttributes'].get('user_type', '')
logger.info(event)
if user_type == 'TYPE1':
response = cognito_client.admin_disable_user(
UserPoolId=event['userPoolId'],
Username=event['userName']
)
logger.info(response)
return event
这将返回以下错误:
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the AdminDisableUser operation: User: arn:aws:sts::<accound_id>:assumed-role/CognitoPostConfirmation-role-xxxxx/CognitoPostConfirmation is not authorized to perform: cognito-idp:AdminDisableUser on resource: arn:aws:cognito-idp:us-east-1:xxxxxx:userpool/us-east-1_xxxxxx
有没有办法在使用触发器时禁用某些类型的用户?我也尝试过使用预注册,但这里的问题是所有其他类型的用户都需要自动确认,这不是我想要的。我需要普通用户接收确认电子邮件,而某种类型的用户需要接收确认然后被禁用或不被确认。
我真的很感激这方面的任何帮助
谢谢,