title: python code to send notification to Microsoft teams FROM AWS lambda
body: <p>Idea is to notify the message coming from cloud watch alarm to Microsoft teams. The messages is in the cloud watch alarm description.</p>
  <p>Below is the JSON which is passed to lambda:</p>
  <pre><code>{   'Records': [{       'EventSource': 'aws:sns',       'EventVersion': '1.0',      'EventSubscriptionArn': '71d-4f70-927e-0a420040a154',       'Sns': {            'Type': 'Notification',             'MessageId': '152c308c--bca8-67281c9c3c36',',           'Subject': 'ALARM: &quot;StoreException-&quot; in ()',            'Message': '{&quot;AlarmName&quot;:&quot;StoreException-WAS102&quot;,&quot;AlarmDescription&quot;:&quot;StoreClosedException-in-1.1.1.1&quot;,&quot;AWSAccountId&quot;:&quot;xxxxx&quot;,&quot;NewStateValue&quot;:&quot;ALARM&quot;}}
  </code></pre>
  <p>Below is my python lambda code:</p>
  <pre><code>    import urllib3 
      import json
      http = urllib3.PoolManager() 
      def lambda_handler(event, context): 
          print(event)
          message = event['Records'][0]['Sns']['Message']
          alarm_name = message['AlarmName']
          app_name = message['AlarmDescription']
          msg = {
         
              &quot;text&quot;: app_name
          }
          encoded_msg = json.dumps(msg).encode('utf-8')
          resp = http.request('POST',url, body=encoded_msg)
      
  </code></pre>
  <p>But i am getting error as below:</p>
  <pre><code>&gt; string indices must be integers: TypeError Traceback (most recent call
  &gt; last):   File &quot;/var/task/lambda_function.py&quot;, line 15, in
  &gt; lambda_handler
  &gt;     &quot;text&quot;: app_name TypeError: string indices must be integers
  </code></pre>
  <p>I think i am getting the issue while using the dict. But not sure how to make it work. Can anyone help me out.</p>