Skip to content

Commit

Permalink
Merge pull request #805 from companieshouse/feature/DVOP-3122-confirm…
Browse files Browse the repository at this point in the history
…ation-statment-web-ecs-terraform-update

Feature/dvop 3122 confirmation statment web ecs terraform update
  • Loading branch information
cryder-ch authored Jan 23, 2025
2 parents 8ec6e9a + 393a1b5 commit 0940016
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 43 deletions.
28 changes: 15 additions & 13 deletions terraform/groups/ecs-service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ terraform {
}

provider "aws" {
region = var.aws_region
region = var.aws_region
}

terraform {
backend "s3" {}
}

module "secrets" {
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/secrets?ref=1.0.287"
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/secrets?ref=1.0.296"

name_prefix = "${local.service_name}-${var.environment}"
environment = var.environment
Expand All @@ -29,7 +29,7 @@ module "secrets" {
}

module "ecs-service" {
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/ecs-service?ref=1.0.287"
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/ecs-service?ref=1.0.296"

# Environmental configuration
environment = var.environment
Expand All @@ -46,21 +46,23 @@ module "ecs-service" {

# ECS Task container health check
use_task_container_healthcheck = true
healthcheck_path = local.healthcheck_path
healthcheck_matcher = local.healthcheck_matcher
healthcheck_path = local.healthcheck_path
healthcheck_matcher = local.healthcheck_matcher

# Docker container details
docker_registry = var.docker_registry
docker_repo = local.docker_repo
container_version = var.confirmation_statement_web_version
container_port = local.container_port
docker_registry = var.docker_registry
docker_repo = local.docker_repo
container_version = var.confirmation_statement_web_version
container_port = local.container_port


# Service configuration
service_name = local.service_name
name_prefix = local.name_prefix

# Service performance and scaling configs
desired_task_count = var.desired_task_count
min_task_count = var.min_task_count
max_task_count = var.max_task_count
required_cpus = var.required_cpus
required_memory = var.required_memory
Expand All @@ -76,10 +78,10 @@ module "ecs-service" {
cloudwatch_alarms_enabled = var.cloudwatch_alarms_enabled

# Service environment variable and secret configs
task_environment = local.task_environment
task_secrets = local.task_secrets
app_environment_filename = local.app_environment_filename
use_set_environment_files = local.use_set_environment_files
task_environment = local.task_environment
task_secrets = local.task_secrets
app_environment_filename = local.app_environment_filename
use_set_environment_files = local.use_set_environment_files

depends_on = [module.secrets]
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
environment = "cidev"
aws_profile = "development-eu-west-2"

# service configs
use_set_environment_files = true
log_level = "debug"

# Scheduled scaling of tasks
service_autoscale_enabled = true
service_scaledown_schedule = "55 19 * * ? *"
service_scaleup_schedule = "5 6 * * ? *"
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
environment = "phoenix1"
aws_profile = "development-eu-west-2"

# service configs
use_set_environment_files = true
log_level = "debug"

# Scheduled scaling of tasks
service_autoscale_enabled = true
service_scaledown_schedule = "55 19 * * ? *"
service_scaleup_schedule = "5 6 * * ? *"
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ environment = "live"
aws_profile = "live-eu-west-2"

# service configs
use_set_environment_files = true
desired_task_count = 2 # use multi instance in stagingenvironment = "live"
desired_task_count = 2
min_task_count = 2
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
environment = "staging"
aws_profile = "staging-eu-west-2"

# service configs
use_set_environment_files = true

# scaling configs
desired_task_count = 2 # use multi instance in staging

# Scheduled scaling of tasks
service_scaledown_schedule = "55 19 * * ? *"
service_scaleup_schedule = "5 6 * * ? *"
34 changes: 19 additions & 15 deletions terraform/groups/ecs-service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,30 @@ variable "docker_registry" {
# Service performance and scaling configs
# ------------------------------------------------------------------------------
variable "desired_task_count" {
type = number
type = number
description = "The desired ECS task count for this service"
default = 1 # defaulted low for dev environments, override for production
default = 1 # defaulted low for dev environments, override for production
}
variable "required_cpus" {
type = number
description = "The required cpu resource for this service. 1024 here is 1 vCPU"
default = 256 # defaulted low for dev environments, override for production
}
variable "required_memory" {
type = number
description = "The required memory for this service"
default = 512 # defaulted low for node service in dev environments, override for production
variable "min_task_count" {
type = number
description = "The minimum number of tasks for this service."
default = 1
}

variable "max_task_count" {
type = number
description = "The maximum number of tasks for this service."
default = 3
}
variable "required_cpus" {
type = number
description = "The required cpu resource for this service. 1024 here is 1 vCPU"
default = 256 # defaulted low for dev environments, override for production
}
variable "required_memory" {
type = number
description = "The required memory for this service"
default = 512 # defaulted low for node service in dev environments, override for production
}

variable "use_fargate" {
type = bool
Expand Down Expand Up @@ -75,15 +79,15 @@ variable "service_scaledown_schedule" {
# Typically used to stop all tasks in a service to save resource costs overnight.
# E.g. a value of '55 19 * * ? *' would be Mon-Sun 7:55pm. An empty string indicates that no schedule should be created.

default = ""
default = ""
}
variable "service_scaleup_schedule" {
type = string
description = "The schedule to use when scaling up the number of tasks to their normal desired level."
# Typically used to start all tasks in a service after it has been shutdown overnight.
# E.g. a value of '5 6 * * ? *' would be Mon-Sun 6:05am. An empty string indicates that no schedule should be created.

default = ""
default = ""
}

# ----------------------------------------------------------------------
Expand All @@ -106,7 +110,7 @@ variable "ssm_version_prefix" {

variable "use_set_environment_files" {
type = bool
default = false
default = true
description = "Toggle default global and shared environment files"
}
variable "log_level" {
Expand Down

0 comments on commit 0940016

Please sign in to comment.