hands-on lab

Utilizing Lightswitch and Janitor Patterns for Cost Optimization of AWS Cloud Resources

Up to 1h
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.


In this hands-on lab, you'll dive into the practical application of Lightswitch and Janitor patterns, essential methodologies for cost-saving and efficient resource management within Amazon Web Services (AWS). You’ll learn how to use the Lightswitch pattern to intelligently turn off running compute instances during non-utilization periods to minimize costs. Additionally, you’ll explore the Janitor pattern, focusing on the identification and deletion of unused and untagged resources to declutter the AWS cloud environment and reduce unnecessary expenses.

You’ll learn how to deploy and configure a set of Python-based Lambda Functions which perform various cost optimization strategies within the lab-provided AWS account. The first Lambda Function will implement the Lightswitch pattern to scan running EC2 instances within the lab-provided AWS account and perform various actions based on the tagging configuration applied to each EC2 instance. The second Lambda Function will implement the Janitor pattern to detect unused/unreferenced AWS resources (EBS volumes, EIPs, etc.).

Learning objectives

At the conclusion of this hands-on lab, you’ll have learnt the following actionable strategies to effectively optimize your own AWS cloud resources:

  • Applying cost management and operational efficiency strategies to various AWS resources
  • Applying the light pattern with tagging to cost-optimise compute resources
  • Applying the janitor pattern to identify unused cloud resources
  • Leverage event-driven architectures to run ad-hoc cost optimization processes

Intended audience

  • Cloud Architects
  • DevOps Engineers
  • Software Engineers


Familiarity with the following will be beneficial but is not required:

  • FinOps
  • Cost Optimization
  • Event-Driven Architecture
  • AWS Lambda

The following content can be used to fulfill the prerequisites:

Environment before

Environment after

About the author

Jeremy Cook, opens in a new tab
Content Lead Architect
Learning paths

Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, Azure, GCP), Security, Kubernetes, and Machine Learning.

Jeremy holds professional certifications for AWS, Azure, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).

Covered topics

Lab steps

Logging In to the Amazon Web Services Console
IDE Access
Implement the Lightswitch Pattern
Implement the Janitor Pattern