def __store_message()

in ingest_er7_service/ingest_er7_lambda.py [0:0]


def __store_message(idToken, msg, key, tags, msg_hash, source):
  logger.debug("Getting user credentials")
  credentials = __get_credentials(
    os.environ['user_pool_id'], 
    os.environ['identity_pool_id'], 
    os.environ['cognito_endpoint'], 
    idToken
  )
  
  client = __get_client('s3', credentials) # Client with user credentials
  
  logger.debug("Putting in the bucket")
  client.put_object(
    Bucket=os.environ['bucket_name'],
    Key=key,
    Body=msg,
    ContentType="text/plain; charset=utf-8",
    Tagging=tags
  )
  
   # Update DynamoDB message table
  logger.debug("Writing to our DynamoDB table")
  table.put_item(
    Item={
      'source': source,
      'message_id': msg_hash,
      'bucket': os.environ['bucket_name'],
      'key': key
    }
  )