import json
import os

from sns_utils import publish_sns_message


def main(event, _):
    print(f'Received event:\n{event}')
    stream_topic_map = json.loads(os.environ["STREAM_TOPIC_MAP"])
    new_image = event['Records'][0]['dynamodb']['NewImage']
    topic_arn = stream_topic_map[event['Records'][0]['eventSourceARN']]
    publish_sns_message(topic_arn,new_image)

import os

from sns_utils import publish_sns_message


def main(event, _):
    print(f'Received event:\n{event}')
    stream_topic_map = os.environ["STREAM_TOPIC_MAP"]
    new_image = event['Records'][0]['dynamodb']['NewImage']
    topic_arn = stream_topic_map[event['Records'][0]['eventSourceARN']]
    publish_sns_message(topic_arn,new_image)

Fix loading of map from environment variables
Fix loading of map from environment variables

- import json
  import os
  
  from sns_utils import publish_sns_message
  
  
  def main(event, _):
      print(f'Received event:\n{event}')
-     stream_topic_map = json.loads(os.environ["STREAM_TOPIC_MAP"])
+     stream_topic_map = os.environ["STREAM_TOPIC_MAP"]
      new_image = event['Records'][0]['dynamodb']['NewImage']
      topic_arn = stream_topic_map[event['Records'][0]['eventSourceARN']]
      publish_sns_message(topic_arn,new_image)
  
Fix loading of map from environment variables
## Code Before:
import json
import os

from sns_utils import publish_sns_message


def main(event, _):
    print(f'Received event:\n{event}')
    stream_topic_map = json.loads(os.environ["STREAM_TOPIC_MAP"])
    new_image = event['Records'][0]['dynamodb']['NewImage']
    topic_arn = stream_topic_map[event['Records'][0]['eventSourceARN']]
    publish_sns_message(topic_arn,new_image)

## Instruction:
Fix loading of map from environment variables
## Code After:
import os

from sns_utils import publish_sns_message


def main(event, _):
    print(f'Received event:\n{event}')
    stream_topic_map = os.environ["STREAM_TOPIC_MAP"]
    new_image = event['Records'][0]['dynamodb']['NewImage']
    topic_arn = stream_topic_map[event['Records'][0]['eventSourceARN']]
    publish_sns_message(topic_arn,new_image)
