Skip to content

New serverless pattern - lambda-invoicing-bedrock-cdk#3195

Open
NithinChandranR-AWS wants to merge 2 commits into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-invoicing-bedrock-cdk
Open

New serverless pattern - lambda-invoicing-bedrock-cdk#3195
NithinChandranR-AWS wants to merge 2 commits into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-invoicing-bedrock-cdk

Conversation

@NithinChandranR-AWS

@NithinChandranR-AWS NithinChandranR-AWS commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

New pattern: Automated AWS Invoice Retrieval and Analysis with Amazon Bedrock

Amazon EventBridge triggers an AWS Lambda function monthly that retrieves invoices via the new AWS Invoicing APIs (ListInvoiceSummaries, GetInvoicePDF), archives PDFs to Amazon S3, and generates cost analysis summaries using Amazon Bedrock.

Pattern details

  • Language: Python
  • Framework: AWS CDK
  • Level: 200

Composition

  • Amazon EventBridge — monthly scheduled trigger
  • AWS Lambda — orchestrates invoice retrieval and analysis
  • AWS Invoicing APIs — programmatic invoice access (launched June 25, 2026)
  • Amazon S3 — PDF archive with lifecycle transitions
  • Amazon Bedrock (Claude Sonnet 4) — cost analysis and optimization recommendations

Removing any service breaks the pattern: no EventBridge = no automation, no Lambda = no orchestration, no S3 = no archive, no Bedrock = no intelligent analysis.

Testing

Deployed and tested in us-east-1. Results:

  • 1 invoice retrieved
  • PDF archived to Amazon S3
  • Amazon Bedrock generated structured executive summary with spend breakdown and recommendations

…nalysis

Amazon EventBridge scheduled AWS Lambda retrieves invoices via new
Invoicing APIs (ListInvoiceSummaries, GetInvoicePDF), archives PDFs
to Amazon S3, and uses Amazon Bedrock to generate cost analysis with
optimization recommendations.

Deployed and tested: 1 invoice retrieved, PDF archived (60KB),
Amazon Bedrock analysis generated with spend summary and recommendations.
@NithinChandranR-AWS

Copy link
Copy Markdown
Contributor Author

"What does this solve that Cost Explorer doesn't?"

The Real Enterprise Pain Point

Enterprise customers have:

  1. Multiple AWS Organizations (M&A, subsidiaries, regional entities, MSP-managed accounts)
  2. Invoice Units mapped to business entities (BU chargebacks, cost centers, legal entities)
  3. Monthly close cycles where finance teams manually download 50-200 PDFs from different payer accounts, rename them, reconcile them against POs, and feed them into SAP/Oracle ERP

The June 25, 2026 blog quotes: "If you manage invoices for dozens or hundreds of AWS payer accounts, you face repetitive console logins, individual file downloads, and manual data entry into your financial systems."

hence the PR. Thanks.

@marcojahn marcojahn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @NithinChandranR-AWS, thank you for your contribution. A few request for changes, pls review.

memorySize: 512,
environment: {
BUCKET_NAME: invoiceBucket.bucketName,
MODEL_ID: 'us.anthropic.claude-sonnet-4-20250514-v1:0',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please upgrade to latest Sonnet models here and on the permissions (role)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, upgraded to Claude Sonnet 4.6 and made the model configurable via CDK context. Thank you for your time and help.


Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.

## Requirements

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stack is tied to us-east-1 only. Please consider to make the region (and therefore model usage) configurable. As this is only a pattern, we see customers/users not having access to all regions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Model ID is now configurable via --context modelId=eu.anthropic.claude-sonnet-4-6 and IAM uses wildcard regions. Thank you for your time and help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants