Connection between fargate driver and ECS task is failing

Replace this template with your information

Describe your question in as much detail as possible:

When trigger a CI job, in ‘Autoscaling GitLab CI on AWS Fargate’ setup, it throws the below error.

ERRO[2021-02-01T10:23:46Z] Application execution failed PID=17244 error=“executing the script on the remote host: executing script on container with IP “”: connecting to server: connecting to server “” as user “root”: dial tcp connect: connection timed out” is container IP. I am sure this is related to the security group on /etc/gitlab-runner/fargate.toml configuration. Can someone explain what is the exact purpose of the security group in the below config.
LogLevel = “info”
LogFormat = “text”

Cluster = “test-cluster”
Region = “us-east-2”
Subnet = “subnet-xxxxxx”
SecurityGroup = “sg-xxxxxxxxxxxxx”
TaskDefinition = “test-task:1”
EnablePublicIP = true

Directory = “/opt/gitlab-runner/metadata”

Username = “root”
Port = 22