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 “3.89.131.50”: connecting to server: connecting to server “3.89.131.50:22” as user “root”: dial tcp 3.89.131.50:22: connect: connection timed out”

3.89.131.50 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”

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

[TaskMetadata]
Directory = “/opt/gitlab-runner/metadata”

[SSH]
Username = “root”
Port = 22