Parsing through json data for aws sns event data in python
<p>I was able to assign the sns event data to a variable using </p>

<pre><code>def lambda_handler(event, context):
    message = event['Records'][0]['Sns']['Message']
    print("From SNS: " + message)
</code></pre>

<p>Output :</p>

<pre><code>{
    "Records": [
        {
            "eventVersion": "2.0",
            "eventSource": "aXXXX",
            "awsRegion": "XXXXX",
            "eventTime": "2016-03-09T12:24:19.255Z",
            "eventName": "ObjectCreated:Put",
            "userIdentity": {
                "principalId": "AWS:XXXXXXXXXXX"
            },
            "requestParameters": {
                "sourceIPAddress": "xxx.xxx.xx.xx"
            },
            "responseElements": {
                "x-amz-request-id": "XXXX",
                "x-amz-id-2": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            },
            "s3": {
                "s3SchemaVersion": "1.0",
                "configurationId": "xxx-xxx-xxx",
                "bucket": {
                    "name": "bucketname",
                    "ownerIdentity": {
                        "principalId": "XXXXXX"
                    },
                    "arn": "arn:aws:s3:::xxxxx"
                },
                "object": {
                    "key": "index.js",
                    "size": 7068,
                    "eTag": "xxxx",
                    "sequencer": "0000000000"
                }
            }
        }
    ]
}
</code></pre>

<p>I am unable to further parse and get the values of <code>awsRegion</code>, <code>Records.s3.bucket.name</code> and <code>Records.s3.object.key</code>.</p>

<p>I have tried <code>bucketname = message['Records'][0]['s3']['bucket']['name']</code>.
getting the error TypeError: string indices must be integers</p>