https://github.com/gordonmurray/terraform_s3_bucket_costs_lambda
A lambda function to list s3 buckets and their size
https://github.com/gordonmurray/terraform_s3_bucket_costs_lambda
finops lambda s3
Last synced: 6 months ago
JSON representation
A lambda function to list s3 buckets and their size
- Host: GitHub
- URL: https://github.com/gordonmurray/terraform_s3_bucket_costs_lambda
- Owner: gordonmurray
- License: mit
- Created: 2024-05-28T07:50:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-28T09:58:33.000Z (over 1 year ago)
- Last Synced: 2025-03-19T21:47:18.954Z (7 months ago)
- Topics: finops, lambda, s3
- Language: HCL
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# S3 Bucket costs using Lambda
A lambda function to list S3 buckets and their sizes.
### Permissions
An IAM user is required for Terraform to create this project in the AWS account.
Follow the steps in [Permission Details](permissions.md) to create an IAM user in your AWS account
### Packaging the Lambda Function
Before deploying, you need to package your Lambda function code (lambda_function.py) into a .zip file:
```
zip lambda.zip lambda_function.py
```### Deploy the Terraform Configuration
```
terraform init
terraform apply
```### Summary log
A log will be written to an s3 bucket. The output will look something like this:
```
Summary as of 2024-01-01 08:00:00 UTCBucket: ec2-webserver-logs-bucket, Size: 23.34 GB, Location: eu-west-1
Bucket: my-test-bucket, Size: 0.29 GB, Location: None
```### Esimated running costs
Assuming the lambda runs once a month and takes 60 minutues to run:
```
Name Monthly Qty Unit Monthly Costaws_lambda_function.s3_summary
├─ Requests 0.0000 1M requests $0.00 *
└─ Duration (first 6B) 450 GB-seconds $0.01 *OVERALL TOTAL $0.01
*Usage costs were estimated using infracost-usage.yml, see docs for other options.
──────────────────────────────────
6 cloud resources were detected:
∙ 1 was estimated
∙ 5 were free┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Project ┃ Baseline cost ┃ Usage cost* ┃ Total cost ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━┫
┃ main ┃ $0.00 ┃ $0.01 ┃ $0.01 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━┛
```