We will now create a Lambda function which will run the code and produce the reports. NOTE: this Lambda function must be created in the same region as S3 bucket for CUR query results created earlier.
Go to the Lambda console, click Create function.
Select Author from scratch, configure the following parameters:
In the top right-hand corner of Lambda configuration page, click Select a test event drop-down box and choose Configure test events.
Use the default event template Hello world, because this function does not need any input event parameters, set a event name AutoCURDeliveryTest, and click Create.
In Function code section, configure the following:
Scroll down to Basic settings section, set Memory to 512 MB, and timeout to 5 min.
Keep other configurations as default, scroll to the very top and click Save. Click the Actions drop-down box and choose Publish new version.
Set the Version description to v1, and click Publish.
We have finished the configuration and we will now test it. Make sure AutoCURDeliveryTest event is selected, click Test.
It takes a few seconds to execute Lambda function, and you’ll see all logs after execution.
Check your e-mail recipients, they should receive a mail for cost & utilization report with an excel file attached, similarly as below:
By default, the cost & utilization report contains:
Now you have completed this auto CUR delivery solution with default CUR query. In the next step we will add an additional query, and a CloudWatch scheduled event to trigger Lambda function as required.