Week 7 Worklog

Week 7 Objectives:

  • Develop the Lambda Analyzer function, the cost analysis and alerting component of the CloudCost Insight system.
  • Read cost data from S3 and implement logic to compare it against the budget threshold to detect cost overruns.
  • Integrate Amazon SNS to send email notifications when costs exceed the defined threshold.
  • Connect SQS to Lambda Analyzer (Event Source Mapping) for automatic event processing, using a dedicated IAM Role that follows the Principle of Least Privilege.
  • Verify the end-to-end analysis and alerting workflow (SQS, Analyzer, S3, SNS, Email).
  • Maintain effective team collaboration by discussing the daily plan before work and summarizing the results at the end of each day.

Tasks Completed During the Week:

DayTaskStart DateCompletion DateReference Materials
Mon- Design the analysis logic and implement the Analyzer:
  + Discuss the daily work plan with the team before starting.
  + Design the logic to read cost data from S3, calculate the total cost, and identify the top cost-consuming services.
  + Implement the logic to compare the total cost against the budget threshold.
  + Develop the Lambda Analyzer using Python and boto3.
  + Summarize the day’s progress and share the results with the team.
22/06/202622/06/2026- AWS Lambda Developer Guide (Python):
https://docs.aws.amazon.com/lambda/latest/dg/lambda-python.html
- Boto3 S3 Client:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html
Tue- Integrate SNS notifications:
  + Discuss the daily work plan with the team before starting.
  + Implement the function to send alerts via Amazon SNS when costs exceed the threshold.
  + Format the alert content (total cost, threshold, and top cost-consuming services).
  + Pass configuration values (BUCKET_NAME, SNS_TOPIC_ARN, COST_THRESHOLD_USD) through environment variables.
  + Summarize the day’s progress and share the results with the team.
23/06/202623/06/2026- Boto3 SNS Publish:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sns.html
- Amazon SNS Developer Guide:
https://docs.aws.amazon.com/sns/latest/dg/
Wed- Write Terraform configuration to deploy the Analyzer and its dedicated IAM Role:
  + Discuss the daily work plan with the team before starting.
  + Create lambda_analyzer.tf: package the source code, create the Lambda function, and configure the CloudWatch Log Group with a retention policy.
  + Create a dedicated IAM Role for the Analyzer following the Principle of Least Privilege (read-only access to S3, receive messages from SQS, and publish to SNS).
  + Summarize the day’s progress and share the results with the team.
24/06/202624/06/2026- Terraform aws_lambda_function:
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function
- IAM Best Practices:
https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
Thu- Connect SQS to Lambda (Event Source Mapping):
  + Discuss the daily work plan with the team before starting.
  + Configure aws_lambda_event_source_mapping so that SQS automatically triggers the Analyzer.
  + Configure the batch size and connect the primary queue to the Analyzer function.
  + Run terraform apply to deploy the Analyzer to AWS.
  + Summarize the day’s progress and share the results with the team.
25/06/202625/06/2026- Terraform aws_lambda_event_source_mapping:
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping
- Using Lambda with SQS:
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
Fri- Test and verify the alerting workflow:
  + Discuss the daily work plan with the team before starting.
  + Temporarily set threshold = -1 to validate the threshold detection logic independently of the Cost Explorer delay (the actual account cost is currently $0).
  + Run the Collector to generate an event and verify that the Analyzer detects the threshold violation through CloudWatch Logs.
  + Confirm that the SNS email notification is successfully received.
  + Summarize the day’s progress and share the results with the team.
26/06/202626/06/2026- Testing Lambda functions:
https://docs.aws.amazon.com/lambda/latest/dg/testing-functions.html
- Amazon CloudWatch Logs.

Week 7 Achievements:

  • Completed the Analysis and Alerting Component (Analyzer): Successfully developed the Lambda Analyzer using Python and boto3. The function can read cost data from S3, calculate the total cost, identify the top cost-consuming services, and compare the total cost against the configured budget threshold to detect cost overruns.
  • Integrated Automatic Email Alerts: Successfully integrated Amazon SNS to send detailed email notifications whenever costs exceed the configured threshold. Each notification includes the total cost, the configured threshold, and the list of the most expensive AWS services, enabling users to quickly assess the situation and take appropriate action.
  • Implemented an Automated and Decoupled Architecture: Configured Event Source Mapping so that SQS automatically triggers the Lambda Analyzer, completing the asynchronous workflow between the Collector and the Analyzer. This architecture improves flexibility, scalability, and overall system resilience.
  • Applied the Principle of Least Privilege: Created a dedicated IAM Role for the Analyzer, separate from the Collector. The Analyzer was granted only the minimum permissions required (read access to S3, receive messages from SQS, and publish notifications to SNS), fully complying with AWS security best practices and strengthening the overall security of the system.
  • Verified the End-to-End Alerting Workflow: Successfully validated the complete workflow by temporarily setting threshold = -1, allowing the threshold detection logic to be tested independently of the 24-hour delay of the Cost Explorer API (while the actual AWS account cost remained at $0). The Analyzer correctly detected the threshold violation, generated detailed CloudWatch Logs, and successfully delivered the alert email through SNS, confirming that the entire analysis and alerting pipeline functioned correctly from end to end.
  • Team Collaboration: Maintained effective collaboration throughout the week. Before starting work each day, I discussed the daily plan with my teammates, and at the end of each day, I summarized the completed tasks to keep everyone informed of the project’s progress.