fetchPricelist is a Lambda function which fetches the latest EC2 offer file when updated. The function is triggered through a SNS subscription, broadcasting notifications when AWS prices change (see: docs.aws.amazon.com).
The function executes a script -Python 3.6 runtime- and downloads a copy of the EC2 offer file to a S3-bucket. This repository contains the Python script and the policy file containing the required permissions the function needs during execution:
- fetchPricelist.py - Python script
- policy.json - IAM policy file
-
The billing metric data is stored in the US East (N. Virginia) Region, meaning if you create the SNS subscription as outined in the documentation, make sure the SNS console has US East (N. Virginia) as selected region.
-
The Lambda function makes use of a Lambda layer, which includes the Pendulum Python library and the Certifi Library
- If you are not familiar with Lambda layers, check our these instructions
- Using the Pendulum library is optional, you can use the Python datetime module instead. An example of a Python script using datetime is included in the
datetime-directory within this repository.
-
Make sure to adapt the IAM Policy file, and replace the placeholder values:
{your-s3-bucket-name}= the S3 bucket the file will be written to,- replace
{region},{account-id}and{funtion-name}in the CloudWatch Log Group ARN with the appropriate values for your environment