AWS Billing Report API:
- Setup billing integration with Athena:
a. https://aws.amazon.com/blogs/aws-cost-management/querying-your-aws-cost-and-usage-report-using-amazon-athena/ - Define, if required, previous month adjustments:
a. - Configure how we will send data to Athena:
a.
b. Reference https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/athena.html. - Create a lambda fuction using the sample code: https://github.com/mpcloud/code/aws-billing-api/blob/master/athena_billing.py
a. Example on hot to create lambda: https://docs.aws.amazon.com/es_es/toolkit-for-eclipse/v1/user-guide/lambda-tutorial.html. - Assign the required values:
a. - You need to have a role previously created with access to S3 ans to query Athena.
- Create a ner API in API Gateway and associate the lambda you currently created mapping the parameters to the lambda input:
a. - Create a resource and a Methos in API Gateway:
a. - Setup the example parameters wou will use in the GET Request to the URL:
a.
b. Method Request
c. Integration Request
i.
ii.
d. Integration Response
e. Method Response
The parameters we defined will be used like this: AccountID=Your-Account-ID&Month=12&Year=2018, we can go to test to validate before deploying, this is an example of how your URL would look like with this example: https://your-url.execute-api.us-east-1.amazonaws.com/Prod/test?AccountID=360616938971&Month=12&Year=2018