title: How to make AWS ECS Task Definition make EC2 instances publicly accessible?
body: <p>Below is my AWS Task Definition for ECS.</p>
  
  <p>I need every EC2 instance of this task to have port 3026 publicly accessible to the world. How can I modify this JSON to do that?</p>
  
  <p>Currently, after service is running this task, I manually find the EC2 instance(s) and then I manually add a security group that allows ingress from 0.0.0.0/0 on that port. </p>
  
  <p>But I really want to know how to make this JSON do it so I no longer have to do it manually.</p>
  
  <pre><code>{
      "family": "myproj",
      "requiresCompatibilities": [
          "EC2"
      ],
      "containerDefinitions": [
          {
              "memory": 500,
              "memoryReservation": 350,
              "name": "myproj",
              "image": "blah.dkr.ecr.us-east-1.amazonaws.com/myproj:latest",
              "essential": true,
              "portMappings": [
                  {
                      "hostPort": 3026,
                      "containerPort": 8000,
                      "protocol": "tcp"
                  }
              ],
              "entryPoint": [
                  "./entrypoint_deployment.sh"
              ],
              "environment" : [
                  { "name" : "DB_HOST", "value" : "blah.blah.us-east-1.rds.amazonaws.com" }
              ],
              "logConfiguration": {
                  "logDriver": "awslogs",
                  "options": {
                      "awslogs-group": "/ecs/myproj",
                      "awslogs-region": "us-east-1",
                      "awslogs-stream-prefix": "ecs"
                  }
              }
  
          }
      ]
  }
  </code></pre>