Automated AWS Invoice Retrieval and Analysis with Amazon Bedrock

Amazon EventBridge → AWS Lambda → Amazon S3 → Amazon Bedrock

Retrieve AWS invoices programmatically, archive PDFs to Amazon S3, and generate cost analysis summaries using Amazon Bedrock.

An Amazon EventBridge scheduled rule triggers an AWS Lambda function on the 2nd of each month.
The AWS Lambda function calls the AWS Invoicing API to list invoice summaries and download invoice PDFs via presigned URLs.
Invoice PDFs are archived to Amazon S3 with date-partitioned prefixes and lifecycle transitions to Infrequent Access.
Amazon Bedrock analyzes the invoice data and generates an executive summary with cost optimization recommendations.
The analysis results are stored alongside the PDFs in Amazon S3 for historical tracking and audit compliance.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-invoicing-bedrock-cdk

Deploy

<code>cdk bootstrap</code><code>npm install</code><code>cdk deploy</code>


Testing

Invoke the AWS Lambda function manually to test invoice retrieval:
aws lambda invoke --function-name $(aws cloudformation describe-stacks --stack-name LambdaInvoicingBedrockStack --query 'Stacks[0].Outputs[?OutputKey==`FunctionName`].OutputValue' --output text) --payload '{}' response.json && cat response.json

Cleanup

Warning: This will delete the Amazon S3 bucket and all archived invoices.
cdk destroy

Created by:

Nithin Chandran R

Nithin Chandran R

Technical Account Manager at AWS

Follow on LinkedIn