I wrote a function that creates a report for me and uploads it to S3. However, I have problems filling the CSV file with content. Here you can see the code:
import boto3
import re
import csv
def lambda_handler(event,context):
    client = boto3.client('ce')
    response = client.get_cost_and_usage(
        TimePeriod={
            'Start': "2019-05-15",
            'End':  "2019-07-05"
        },
        Granularity='MONTHLY',
        Metrics=['BlendedCost'],
        GroupBy=[
            {
                'Type': 'TAG',
                'Key': 'Project'
            },
        ]
    )
    csv_testerinho = csv.writer(open("/tmp/csv_testerinho.csv", "w+"))
    csv_testerinho.writerow(["Account Name", "Month", "Cost"])
    #writing rows in csv
    for detail in response:
       csv_testerinho.writerow([response['Start'],
                                response['End'],
                                response['BlendedCost']
                                ])
    client = boto3.client('s3')
    client.upload_file('/tmp/csv_testerinho.csv', 'bucket_name','final_testerinho.csv')
When I execute the code I get the following error:
Response:
{
  "errorMessage": "'Start'",
  "errorType": "KeyError",
  "stackTrace":
}
What would I have to do to fill the CSV with the information I get through the API?
 
    