title: Timeout when connecting to ASW Cognito from Lambda
body: <p>I have Django apllication deployed to AWS Lambda with Cognito as User DB.</p>
  
  <p>For creating user I use management command which creates user in Cognito:</p>
  
  <pre><code>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
          },
      ]
  )
  </code></pre>
  
  <p>When I run this code locally, everything is OK, user is creating. But when I run this command from lambda every time I get timeout.</p>
  
  <p>Here are logs from lambda:</p>
  
  <pre><code>Registering...
  ClientId=************************
  [DEBUG] 2020-05-04T15:22:28.620Z    b65c34a0-9338-4ae5-a49f-4dc287bc4a60    Event before-parameter-build.cognito-identity-provider.SignUp: calling handler &lt;function generate_idempotent_uuid at 0x7f0d9a9583b0&gt;
  [DEBUG] 2020-05-04T15:22:28.621Z    b65c34a0-9338-4ae5-a49f-4dc287bc4a60    Event before-call.cognito-identity-provider.SignUp: calling handler &lt;function inject_api_version_header_if_needed at 0x7f0d9a95ae60&gt;
  [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": "test@gmail.com", "Password": "123123123", "UserAttributes": [{"Name": "custom:role", "Value": "owner"}, {"Name": "email", "Value": "test@gmail.com"}, {"Name": "name", "Value": ""}]}', 'url': 'https://cognito-idp.ap-southeast-1.amazonaws.com/', 'context': {'client_region': 'ap-southeast-1', 'client_config': &lt;botocore.config.Config object at 0x7f0d959e2d90&gt;, '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 &lt;bound method RequestSigner.handler of &lt;botocore.signers.RequestSigner object at 0x7f0d959e2d50&gt;&gt;
  [DEBUG] 2020-05-04T15:22:28.621Z    b65c34a0-9338-4ae5-a49f-4dc287bc4a60    Event choose-signer.cognito-identity-provider.SignUp: calling handler &lt;function set_operation_specific_signer at 0x7f0d9a9558c0&gt;
  [DEBUG] 2020-05-04T15:22:28.621Z    b65c34a0-9338-4ae5-a49f-4dc287bc4a60    Sending http request: &lt;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'}&gt;
  [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
  </code></pre>
  
  <p>What it could be?</p>