Skip to content

Commit

Permalink
chore: Tiny fixes (#34)
Browse files Browse the repository at this point in the history
Fixes #
  • Loading branch information
rajyan authored Sep 11, 2022
1 parent 56ea520 commit c0b7690
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
54 changes: 36 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
[![NPM version](https://badge.fury.io/js/low-cost-ecs.svg)](https://www.npmjs.com/package/low-cost-ecs)
[![PyPI version](https://badge.fury.io/py/low-cost-ecs.svg)](https://pypi.org/project/low-cost-ecs/0.0.4/)
[![PyPI version](https://badge.fury.io/py/low-cost-ecs.svg)](https://pypi.org/project/low-cost-ecs)
[![Release](https://github.com/rajyan/low-cost-ecs/workflows/release/badge.svg)](https://github.com/rajyan/low-cost-ecs/actions/workflows/release.yml)
[<img src="https://constructs.dev/badge?package=low-cost-ecs" width="150">](https://constructs.dev/packages/low-cost-ecs)

# Low-Cost ECS

A CDK construct that provides easy and low-cost ECS on EC2 server setup without a load balancer.
TLS/SSL certificates are installed automatically on startup of the server and renewed by a scheduled state machine using [certbot-dns-route53](https://certbot-dns-route53.readthedocs.io/en/stable/).
A CDK construct that provides easy and [low-cost](#cost) ECS on EC2 server setup without a load balancer.

**This construct is for development purposes only** see [Limitations](#Limitations).
**This construct is for development purposes only** see [Limitations](#limitations).

# Try it out!

The easiest way to see what this construct creates is to clone this repository and deploying sample server.
Edit settings in `bin/low-cost-ecs.ts` and deploy cdk construct. [Public hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html) with your own domain is required.
The easiest way to see what this construct creates is to clone this repository and deploying a sample server.
Edit settings in `bin/low-cost-ecs.ts` and deploy cdk construct. [Public hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html) is required.

```
git clone https://github.com/rajyan/low-cost-ecs.git
Expand All @@ -25,7 +24,7 @@ Access to configured `recordDomainNames` and see that the nginx sample server ha

# Installation

To use this construct in your own cdk stack as a library,
To use this construct in your cdk stack as a library,

```
npm install low-cost-ecs
Expand All @@ -40,9 +39,9 @@ class SampleStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

const vpc = /** Your VPC */;
const securityGroup = /** Your security group */;
const serverTaskDefinition = /** Your task definition */;
const vpc = { /** Your VPC */ };
const securityGroup = {/** Your security group */ };
const serverTaskDefinition = {/** Your task definition */ };

new LowCostECS(this, 'LowCostECS', {
hostedZoneDomain: "rajyan.net",
Expand All @@ -56,18 +55,37 @@ class SampleStack extends Stack {
```

The required fields are `hostedZoneDomain` and `email`.
Set your own task definition, and other props. Read [`LowCostECSProps` documentation](https://github.com/rajyan/low-cost-ecs/blob/main/API.md#low-cost-ecs.LowCostECSProps) for details.
You can configure your server task definition, and other props. Read [`LowCostECSProps` documentation](https://github.com/rajyan/low-cost-ecs/blob/main/API.md#low-cost-ecs.LowCostECSProps) for details.

# Why

ECS may often seem expensive when used for personal development purposes, because of the cost of load balancer.
ECS may often seem expensive when used for personal development purposes, because of the cost of the load balancer.
The application load balancer is a great service because it is easy to set up managed ACM certificates, it scales, and has dynamic port mapping,
but it is over-featured for running 1 ECS service.

However, to run a ECS sever without a load balancer, you need to associate an Elastic IP to the host instance, and install your certificate by yourself.
This construct aims to automate these work and deploying resources to run low-cost ECS server.

[//]: # (# Overview)
However, to run an ECS sever without a load balancer, you need to associate an Elastic IP to the host instance and install your certificate by yourself.
This construct aims to automate these works and deploy resources to run a low-cost ECS server.

# Overview

Resources generated in this stack

* Route53 A record
* Forwarding to host instance Elastic IP
* Certificate State Machine
* Install and renew certificates to EFS using [certbot-dns-route53](https://certbot-dns-route53.readthedocs.io/en/stable/)
* Scheduled automated renewal every 60 days
* Email notification on certbot task failure
* ECS on EC2 host instance
* ECS-optimized Amazon Linux 2 AMI instance auto scaling group
* Automatically associated with Elastic IP on instance initialization
* ECS Service
* TLS/SSL certificate installation on default container startup
* Certificate EFS mounted on `/etc/letsencrypt`
* Others
* VPC with only public subnets (no NAT Gateways to decrease cost)
* Security groups with minimum inbounds
* IAM roles with minimum privileges

# Cost

Expand All @@ -76,7 +94,7 @@ All resources except Route53 HostedZone should be included in [AWS Free Tier](ht
After your 12 Months Free period, setting [`hostInstanceSpotPrice`](https://github.com/rajyan/low-cost-ecs/blob/main/API.md#low-cost-ecs.LowCostECSProps.property.hostInstanceSpotPrice) to use spot instances is recommended.

* EC2
* t2,micro 750 instance hours (12 Months Free Tier)
* t2.micro 750 instance hours (12 Months Free Tier)
* 30GB EBS volume (12 Months Free Tier)
* ECS
* No additional charge because using ECS on EC2
Expand Down Expand Up @@ -112,6 +130,6 @@ aws ecs execute-command \

# Limitations

The ecs service occupies the host port, only one service can be run at a time.
The ECS service occupies the host port, only one service can be run at a time.
The old task must be terminated before the new task launches, and this causes downtime on release.
Also, if you make changes that require recreating service, you may need to manually terminate the task of old the service.
1 change: 0 additions & 1 deletion todo.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# todo

* update Overview
* add properties to expose

0 comments on commit c0b7690

Please sign in to comment.