Answer the question
In order to leave comments, you need to log in
Timeout on query in Cognito from Lambda?
Good day.
I have a Django application on AWS Lambda, with Cognito for users.
To create a user, I use a management command that goes to cognito and registers the user there:
client = boto3.client(
'cognito-idp',
aws_access_key_id=settings.AMAZON_ACCESS_KEY_ID,
aws_secret_access_key=settings.AMAZON_SECRET_ACCESS_KEY,
region_name=settings.AWS_DEFAULT_REGION
)
print('Registering...')
print(f'ClientId={settings.COGNITO_AUDIENCE}')
register_response = client.sign_up(
ClientId=settings.COGNITO_AUDIENCE,
Username=user.email,
Password=password,
UserAttributes=[
{
'Name': 'custom:role',
'Value': user.role
},
{
'Name': 'email',
'Value': user.email
},
{
'Name': 'name',
'Value': user.name
},
]
)
Registering...
ClientId=************************
[DEBUG] 2020-05-04T15:22:28.620Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Event before-parameter-build.cognito-identity-provider.SignUp: calling handler <function generate_idempotent_uuid at 0x7f0d9a9583b0>
[DEBUG] 2020-05-04T15:22:28.621Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Event before-call.cognito-identity-provider.SignUp: calling handler <function inject_api_version_header_if_needed at 0x7f0d9a95ae60>
[DEBUG] 2020-05-04T15:22:28.621Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Making request for OperationModel(name=SignUp) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.SignUp', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.12.22 Python/3.7.7 Linux/4.14.165-102.205.amzn2.x86_64 exec-env/AWS_Lambda_python3.7 Botocore/1.15.22'}, 'body': b'{"ClientId": "**********************", "Username": "[email protected]", "Password": "123123123", "UserAttributes": [{"Name": "custom:role", "Value": "owner"}, {"Name": "email", "Value": "[email protected]"}, {"Name": "name", "Value": ""}]}', 'url': 'https://cognito-idp.ap-southeast-1.amazonaws.com/', 'context': {'client_region': 'ap-southeast-1', 'client_config': <botocore.config.Config object at 0x7f0d959e2d90>, 'has_streaming_input': False, 'auth_type': 'none'}}
[DEBUG] 2020-05-04T15:22:28.621Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Event request-created.cognito-identity-provider.SignUp: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f0d959e2d50>>
[DEBUG] 2020-05-04T15:22:28.621Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Event choose-signer.cognito-identity-provider.SignUp: calling handler <function set_operation_specific_signer at 0x7f0d9a9558c0>
[DEBUG] 2020-05-04T15:22:28.621Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-1.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.SignUp', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.12.22 Python/3.7.7 Linux/4.14.165-102.205.amzn2.x86_64 exec-env/AWS_Lambda_python3.7 Botocore/1.15.22', 'Content-Length': '257'}>
[DEBUG] 2020-05-04T15:22:28.622Z b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Starting new HTTPS connection (1): cognito-idp.ap-southeast-1.amazonaws.com:443
END RequestId: b65c34a0-9338-4ae5-a49f-4dc287bc4a60
REPORT RequestId: b65c34a0-9338-4ae5-a49f-4dc287bc4a60 Duration: 30030.28 ms Billed Duration: 30000 ms Memory Size: 512 MB Max Memory Used: 148 MB Init Duration: 546.39 ms
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question