title: How to access context.identity from a Python AWS Lambda function?
body: <p>My lambda function is receiving a context.</p>
  
  <pre><code>def lambda_handler(event, context):
      logger.info(context.function_name)
      logger.info(context.identity)
      logger.info(context.cognito_identity_id)
      logger.info(context.identity.cognito_identity_id)
      return 'hello world'
  </code></pre>
  
  <p>The log receives the function_name, and logs the memory address for <code>context.identity</code>. But <code>context.cognito_identity_id</code> and <code>context.identity.cognito_identity_pool_id</code> are reported as <code>None</code>.</p>
  
  <p>How do I get <code>cognito_identity_id</code> populated?</p>
  
  <p>From Xcode debugger in the class built by AWS API Gateway I can see that the private variable `_configuration._credentialsProvider._identityId is set correctly. But this value isn't being passed thru to my AWS Lambda function.</p>
  
  <p>I can't find how to get is passed thru. I've read this <a href="http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html" rel="nofollow">page</a> where I'd expect it to be covered.</p>
  
  <p>Further:
  From the Lambda function I logged out <code>dir(context.identity)</code> giving <code>['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', 'cognito_identity_id', 'cognito_identity_pool_id']</code></p>
  
  <p>This shows that <code>cognito_identity_id</code> and <code>cognito_identity_id</code> are actually present.</p>
  
  <p>I think AWS Gateway -> AWS Lambda doesn't set-up Identity for free - I'm missing some configuration - a mapping template perhaps.</p>