Good day.
I hope you all are having a good day.
We run all of our workloads in a ECS cluster on containers, backed my EC2 instances in an Auto Scaling Group.
Now I need to deploy a new service - a Google Lighthouse server and that's fine, but we need persistent storage to store the reports.
I run all of our deployments and manage the infrastructure with Terraform.
The challenge I have is that I want to deploy a standalone EBS volume that needs to be used by the new ECS service container.
I've been following this guide here - https://rewind.com/blog/ebs-volumes-with-ecs-terraform/ - and I've been battling with this for more than a month now. I just cannot get it to work.
When I create the EBS volume and I try to deploy the task definition referencing that volume, Terraform simply tells me "ClientException: Unknown volume 'ecs-ebs-volume'" even though an EBS volume with that name exists.
My Auto Scaling Group does have the permissions for EBS management.
Please see below my ECS service block and task definition (some details have been changed for privacy reasons):
ECS Services Array...
{
name = "lighthouse"
security_groups = ["${module.auto_scaling_group.auto_scaling_group_security_group_id}"]
vpc_subnets = module.vpc.vpc_public_subnets
assign_public_ip = false
memory_target_metric = 90
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 100
autoscaling_min_capacity = 1
desired_count = 1
autoscaling_max_capacity = 2
target_group_arn = module.application_load_balancer.target_group_arn[6]
enable_execute_command = true
tasks = {
family = "lighthouse-staging"
containerPort = 9001
hostPort = var.host_service_port["lighthouse"]
source_volume = "ecs-ebs-volume"
container_path = "/mnt/ecs-ebs-volume"
container_definitions = templatefile("../modules/task-definitions/lighthouse.json.tpl", {
hostPort = var.host_service_port["lighthouse"]
source_volume = "ecs-ebs-volume"
container_path = "/mnt/ecs-ebs-volume"
})
}
}
[
{
"name": "lighthouse-staging",
"image": "account-id.dkr.ecr.region.amazonaws.com/lighthouse:staging",
"cpu": 0,
"memory": 1024,
"essential": true,
"portMappings": [
{
"name" : "lighthouse-staging-9001-tcp",
"containerPort" : 9001,
"hostPort" : ${hostPort},
"protocol" : "tcp"
}
],
"mountPoints": [
{
"sourceVolume": "${source_volume}",
"containerPath": "${container_path}"
}
],
"volume": {
"name": "ecs_ebs_volume",
"docker_volume_configuration": {
"scope": "shared",
"autoprovision": true,
"driver": "rexray/ebs",
"driver_opts": {
"volumetype": "gp3",
"size": 20
}
}
},
"environment": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/lighthouse-staging",
"awslogs-region": "region",
"awslogs-stream-prefix": "ecs"
}
}
}
]
Please forgive me if anything looks wrong or off. I'm still a Terraform novice.
I'd appreciate any suggestions or feedback immensely.
Thank you in advance,
Nic