Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
734eba3
docs(ecs): added a simple locustfile to easily generate some traffic …
mskrajnowski Apr 24, 2020
b1f8435
feat(ecs/services/web): added response status related cloudwatch metr…
mskrajnowski Apr 24, 2020
53d57a2
feat(ecs/services/web): added response time cloudwatch metrics and da…
mskrajnowski Apr 24, 2020
3b9bdf4
feat(ecs/services/web): added cloudwatch metrics and widgets for cpu …
mskrajnowski Apr 27, 2020
ab220ff
feat(ecs/services/web): added connection errors metrics and added the…
mskrajnowski Apr 27, 2020
5dce287
refactor(ecs/services/web): renamed metric_responses to metric_requests
mskrajnowski Apr 27, 2020
c403014
feat(ecs): enabled container insights
mskrajnowski Apr 27, 2020
a659e61
docs(ecs): adjusted example tasks memory and cpu requirements
mskrajnowski Apr 27, 2020
a9ff528
refactor(ecs/services/web): renamed widget_cpu/_memory to _cpu_reserv…
mskrajnowski Apr 27, 2020
b9919ec
refactor(ecs/services/web): switch to container insights metrics for …
mskrajnowski Apr 27, 2020
18f23e0
refactor(ecs/services/web): changed tasks widget to scaling widget us…
mskrajnowski Apr 27, 2020
36b3882
feat(ecs/services/web): prefixed widget titles with the service name
mskrajnowski Apr 27, 2020
b48dbed
refactor(ecs/services/web): moved metrics and widgets to separate fil…
mskrajnowski Apr 27, 2020
1e9a3c6
feat(ecs/services/web): added healthy_tasks metric and added it to sc…
mskrajnowski Apr 27, 2020
b7a490d
feat(ecs/services/worker): added cloudwatch metrics and widgets
mskrajnowski Apr 27, 2020
bf5cf19
Merge branch 'master' into feat/ecs-services-dashboards
mskrajnowski Apr 28, 2020
f319060
Merge branch 'master' into feat/ecs-services-dashboards
mskrajnowski Apr 29, 2020
227a729
refactor(ecs/services/worker): DRYing out the code with cloudwatch/me…
mskrajnowski Apr 29, 2020
4cd5c86
refactor(ecs/services/web): DRYing out code with cloudwatch/metric/ma…
mskrajnowski Apr 29, 2020
48eaad4
Merge branch 'master' into feat/ecs-services-dashboards
mskrajnowski May 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ecs/example/locust/locustfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import random

from locust import HttpLocust, TaskSet, task, between


class UserBehaviour(TaskSet):
@task(5)
def status_2xx(self):
self.client.get("/status/200")

@task(2)
def status_3xx(self):
self.client.get("/redirect-to", params=dict(
url="/status/200",
status_code=302,
))

@task(2)
def status_4xx(self):
self.client.get("/status/400")

@task(1)
def status_5xx(self):
self.client.get("/status/500")


class WebsiteUser(HttpLocust):
task_set = UserBehaviour
wait_time = between(5, 10)
10 changes: 10 additions & 0 deletions ecs/example/locust/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -eux

docker run \
-p 8089:8089 \
--volume "$PWD/locust/locustfile.py:/mnt/locust/locustfile.py" \
-e LOCUSTFILE_PATH=/mnt/locust/locustfile.py \
-e TARGET_URL="$(terraform output lb_url)" \
locustio/locust
33 changes: 30 additions & 3 deletions ecs/example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ module "worker_task" {
environment = local.environment
task = "worker"
image = "kennethreitz/httpbin:latest"
memory_soft_limit = 128
memory_soft_limit = 48
cpu = 128

environment_variables = {
DEBUG = "True"
Expand All @@ -72,7 +73,8 @@ module "web_task" {
environment = local.environment
task = "web"
image = "kennethreitz/httpbin:latest"
memory_soft_limit = 128
memory_soft_limit = 48
cpu = 128
ports = [80]

environment_variables = {
Expand All @@ -87,7 +89,7 @@ module "web" {
name = "web"
cluster_arn = module.cluster.arn
task_definition_arn = module.web_task.arn
desired_count = 1
desired_count = 2

vpc_id = module.cluster.vpc_id
listener_arn = module.cluster.http_listener_arn
Expand All @@ -96,6 +98,31 @@ module "web" {
healthcheck_path = "/"
}

module "dashboard" {
source = "./../../cloudwatch/dashboard"

name = "terraform-ecs-example"
widgets = [
module.web.widgets.responses,
module.web.widgets.response_percentages,
module.web.widgets.response_time,
module.web.widgets.scaling,
module.web.widgets.cpu_utilization,
module.web.widgets.memory_utilization,
module.worker.widgets.scaling,
module.worker.widgets.cpu_utilization,
module.worker.widgets.memory_utilization,
]
}

output "hosts_id" {
value = module.hosts.id
}

output "dashboard_url" {
value = module.dashboard.url
}

output "lb_url" {
value = "http://${module.cluster.load_balancer_domain}"
}
5 changes: 5 additions & 0 deletions ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ resource "aws_ecs_cluster" "cluster" {
count = var.create ? 1 : 0

name = "${var.project}-${var.environment}"

setting {
name = "containerInsights"
value = "enabled"
}
}

8 changes: 8 additions & 0 deletions ecs/services/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,18 @@ Creates an ECS service exposed to the internet using an Application Load Balance

Service id

* `metrics`

Cloudwatch metrics, see [metrics.tf](./metrics.tf)

* `target_group_arn`

Load balancer target group ARN

* `target_group_name`

Load balancer target group name

* `widgets`

Cloudwatch dashboard widgets, see [widgets.tf](./widgets.tf)
1 change: 0 additions & 1 deletion ecs/services/web/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ resource "aws_lb_listener_rule" "service" {
values = [var.rule_path]
}
}

Loading