0
votes

I'm new Terraform and I'm working on an infrastructure setup for deploying Docker Containers. I've based my ECS Cluster off Infrablocks/ECS-Cluster and my Base Networking on Infrablocks/Base-Network. I've opted to use these due to time constraints on the project.

The problem I'm having is that the two EC2 Container Instances that are created by Infrablocks/ECS-Cluster module are not associated with ECS Cluster that Infrablocks builds. I've had zero luck determining why. This is blocking my task definitions from being able to run containers in the ECS Cluster because there are no associated EC2 Instances. I've provided my two dependent module configurations below.

Thank you in advance for any help you can provide!

EC2 with no instances

My Terraform thus far:

module "base_network" {
source  = "infrablocks/base-networking/aws"
version = "2.3.0"

vpc_cidr                            = "10.0.0.0/16"
region                              = "us-east-1"
availability_zones                  = ["us-east-1a", "us-east-1b"]

component                           = "dev-base-network"
deployment_identifier               = "development"

include_route53_zone_association    = "true"

private_zone_id                     = module.route53.private_zone_id

include_nat_gateway                 = "true"}


module "ecs_cluster" {
source                                  = "infrablocks/ecs-cluster/aws"
version                                 = "2.2.0"

region                                  = "us-east-1"
vpc_id                                  = module.base_network.vpc_id
subnet_ids                              = module.base_network.public_subnet_ids

associate_public_ip_addresses           = "yes"

component                               = "dev"
deployment_identifier                   = "devx"

cluster_name = "services"
cluster_instance_ssh_public_key_path    = "~/.ssh/id_rsa.pub"
cluster_instance_type                   = "t2.small"

cluster_minimum_size                    = 2
cluster_maximum_size                    = 10
cluster_desired_capacity                = 2 }
1

1 Answers

1
votes

You'd have to troubleshoot the instance to see why it isn't joining the cluster. On your EC2 instances (which, I have not looked, but I would hope that the "infrablocks" ecs-cluster module uses an AMI with the ECS agent installed), you can look in /var/log/ecs/ecs-agent.log .

If the networking configuration is sound, my first guess would be to check the ECS configuration file. If your module is working properly, it should have populated the config with the cluster name. See here for more on that

(I would have commented instead of answered but this account doesn't have enough rep :shrug:)