https://github.com/codeluminary/aws-cdk-ec2-automation
This project is about automating AWS Elastic compute cloud (EC2) instances by starting them in the morning and terminating them in the evening.
https://github.com/codeluminary/aws-cdk-ec2-automation
automation aws aws-cdk aws-cloudformation aws-ec2 aws-lambda cloud cloud-computing
Last synced: 5 months ago
JSON representation
This project is about automating AWS Elastic compute cloud (EC2) instances by starting them in the morning and terminating them in the evening.
- Host: GitHub
- URL: https://github.com/codeluminary/aws-cdk-ec2-automation
- Owner: CodeLuminary
- Created: 2022-07-15T00:02:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-01T23:37:50.000Z (over 3 years ago)
- Last Synced: 2025-03-02T18:39:23.688Z (about 1 year ago)
- Topics: automation, aws, aws-cdk, aws-cloudformation, aws-ec2, aws-lambda, cloud, cloud-computing
- Language: TypeScript
- Homepage:
- Size: 91.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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)](https://aws.amazon.com/) (Cloud Provider)
- [AWS CLI](https://aws.amazon.com/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](https://nodejs.org/en/) - CDK is build on top of node thus you will need to install nodejs before installing CDK.
- Install and configure [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) 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 :arrow_right: LAMBDA FUNCTION :arrow_right: 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
```
:dancers: :dancers: Violaa :) Your infrastructure have been provision using infrastructure as code.
## 🎩 Author
- IJONI VICTOR 😁😁😁
> Please :pray: don't forget to star :star: the project 😁😁 . Thanks :+1: