Skip to content

This project is about automating AWS Elastic compute cloud (EC2) instances by starting them in the morning and terminating them in the evening.

Notifications You must be signed in to change notification settings

CodeLuminary/aws-cdk-ec2-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

AWS CDK EC2 Automation

This project is about automating AWS Elastic compute cloud (EC2) instances by starting them in the morning (6.00 AM UTC) and terminating them in the evening (11.00 PM UTC). The provisioning of the AWS resources are done using AWS Cloud development kit(CDK).

Technology Stack & Tools

  • Amazon Web Service(AWS) (Cloud Provider)
  • AWS CLI
  • Cloud Development Kit (CDK) - For infrastructure provisioning.
  • Typescript - Language for infrastructure provisioning. Python, C#, Java can also be use.
  • Python - For writing lambda functions for automation. Javascript, C#, Java, Go and Ruby can also be use.

Requirements For Initial Setup

  • Install NodeJS - CDK is build on top of node thus you will need to install nodejs before installing CDK.
  • Install and configure AWS CLI using your generated AWS credentials

AWS SERVICES NEEDED

  • AWS EC2
  • AWS EVENT BRIDGE
  • AWS LAMBDA FUNCTION
  • AWS IAM ROLE

ARCHITECTURE

The event bridge is used to set a cron job which will in turn call lambda function that will in turn start/stop the ec2 instance.

EVENT BRIDGE ➡️ LAMBDA FUNCTION ➡️ EC2

NB: Appropriate IAM role need to be assigned to Lambda to be able to start/stop EC2

Setting Up

1. Fork/Clone/Download the Repository

2. Open project folder in a terminal

3. Install Dependencies:

$ cd cdk

$ npm install

BOOTSTRAP & DEPLOY CDK

In the cdk directory, enter the following command

# To bootstrap the resources declared in the stack
$ cdk bootstrap

# (Optional) To output the cloud formation equivalent of the cdk stacks
$ cdk synth

# To deploy cdk stacks to AWS cloud
$ cdk deploy

👯 👯 Violaa :) Your infrastructure have been provision using infrastructure as code.

🎩 Author

  • IJONI VICTOR 😁😁😁

Please 🙏 don't forget to star ⭐ the project 😁😁 . Thanks 👍

About

This project is about automating AWS Elastic compute cloud (EC2) instances by starting them in the morning and terminating them in the evening.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published