Skip to content

Commit

Permalink
Merge branch 'main' into nd-105
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgreen-moj committed Apr 4, 2024
2 parents b2dc6a1 + 32ed1f3 commit dceffcb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/admin/waf.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ resource "aws_wafv2_ip_set" "authorised_ips" {
name = "authorised-ips"
scope = "REGIONAL"
ip_address_version = "IPV4"
addresses = local.authorised_ips
#addresses = local.authorised_ips
addresses = ["0.0.0.0/1"] #ND-105 temp change to capture all IP addresses, hitting the service.
}

resource "aws_wafv2_web_acl" "admin_alb_acl" {
Expand Down
45 changes: 45 additions & 0 deletions modules/ecs_auto_scaling_radius/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ resource "aws_appautoscaling_policy" "ecs_policy_up" {

depends_on = [aws_appautoscaling_target.radius]
}
// Scaling out using memory utilisation
resource "aws_appautoscaling_policy" "ecs_policy_up_memory_average" {
name = "${var.prefix} ECS Scale Up Memory Average"
service_namespace = "ecs"
policy_type = "StepScaling"
resource_id = "service/${var.cluster_name}/${var.service_name}"
scalable_dimension = "ecs:service:DesiredCount"

step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
metric_aggregation_type = "Average"

step_adjustment {
metric_interval_lower_bound = 0
scaling_adjustment = 1
}
}

depends_on = [aws_appautoscaling_target.radius]
}

resource "aws_appautoscaling_policy" "ecs_policy_down" {
name = "${var.prefix} ECS Scale Down"
Expand Down Expand Up @@ -151,3 +171,28 @@ resource "aws_cloudwatch_metric_alarm" "packets_low" {

tags = var.tags
}

resource "aws_cloudwatch_metric_alarm" "ecs_memory_average_alarm" {
alarm_name = "${var.prefix}-ecs-memory-average-alarm"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "MemoryUtilization"
namespace = "AWS/ECS"
period = "60"
statistic = "Average"
threshold = "70"

dimensions = {
ClusterName = var.cluster_name
ServiceName = var.service_name
}

alarm_description = "This alarm tells ECS to scale up based on average high usage of Memory in the cluster "

alarm_actions = [
aws_appautoscaling_policy.ecs_policy_up_memory_average.arn
]

treat_missing_data = "breaching"
tags = var.tags
}

0 comments on commit dceffcb

Please sign in to comment.