title: How to deploy docker-compose flask project to AWS ECS in gitlab CI
body: <p>My project is a flask project using docker-compose.
  And source code is in GitLab.
  I wanna auto-deploy to ECS with GitLab CI.
  Also, docker images are in ECR.
  But I faced following error.</p>
  <pre><code>Subnet created: subnet-0ffc4936b92c
  Subnet created: subnet-0177c849eeca
  Cluster creation succeeded.
  WARN[0000] Skipping unsupported YAML option for service...  option name=build service name=proxy
  WARN[0000] Skipping unsupported YAML option for service...  option name=container_name service name=proxy
  WARN[0000] Skipping unsupported YAML option for service...  option name=restart service name=proxy
  WARN[0000] Skipping unsupported YAML option for service...  option name=build service name=api
  WARN[0000] Skipping unsupported YAML option for service...  option name=container_name service name=api
  WARN[0000] Skipping unsupported YAML option for service...  option name=restart service name=api
  WARN[0000] Skipping unsupported YAML option for service...  option name=build service name=worker
  WARN[0000] Skipping unsupported YAML option for service...  option name=container_name service name=worker
  WARN[0000] Skipping unsupported YAML option for service...  option name=restart service name=worker
  INFO[0001] Using ECS task definition                     TaskDefinition=&quot;backend:12&quot;
  WARN[0001] No log groups to create; no containers use 'awslogs' 
  ERRO[0001] Error running tasks                           error=&quot;InvalidParameterException: No Container Instances were found in your cluster.&quot; task definition=0xc0005a5ae0
  FATA[0001] InvalidParameterException: No Container Instances were found in your cluster. 
  </code></pre>
  <p>docker-compose.yml</p>
  <pre><code>version: &quot;3.0&quot;
  
  services:
    proxy:
      container_name: rs-proxy
      image: ${REPOSITORY_URL}/proxy
      build:
        context: proxy/.
        dockerfile: Dockerfile
      ports:
        - 80:80
      restart: on-failure
  
    api:
      container_name: rs-api
      image: ${REPOSITORY_URL}/api
      build:
        context: api/.
        dockerfile: Dockerfile.prod
      restart: on-failure
      volumes:
        - ./api/migrations:/app/migrations
  
    worker:
      container_name: rs-worker
      image: ${REPOSITORY_URL}/worker
      build:
        context: .
        dockerfile: ./worker/Dockerfile
      restart: on-failure
  </code></pre>
  <p>.gitlab-ci.yml</p>
  <pre><code>image: tiangolo/docker-with-compose
  
  variables:
    PROJECT_NAME: test-project
    CONFIG_NAME: $PROJECT_NAME
    PROFILE_NAME: $PROJECT_NAME-profile
    AWS_ECR_URL: $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
    REPOSITORY_URL: $AWS_ECR_URL/$PROJECT_NAME
  
  before_script:
    - export REPOSITORY_URL=$REPOSITORY_URL
    - apk add --no-cache curl jq python3 py-pip
    - apk add --update curl
    - pip install awscli
    - curl -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-amd64-latest
    - chmod +x /usr/local/bin/ecs-cli
    - echo &quot;Logging in AWS...&quot;
    - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ECR_URL
  
  stages:
    - build
    - deploy
  
  build:
    stage: build
    script:
      - echo &quot;Building image...&quot;
      - docker-compose -f docker-compose.yml build
      - echo &quot;Pushing image...&quot;
      - docker push ${REPOSITORY_URL}/proxy:latest
      - docker push ${REPOSITORY_URL}/api:latest
      - docker push ${REPOSITORY_URL}/worker:latest
    only:
      - master
  
  deploy:
    stage: deploy
    script:
      - echo &quot;Configuring AWS ECS...&quot;
      - ecs-cli configure --cluster $CONFIG_NAME --default-launch-type EC2 --config-name $CONFIG_NAME --region $AWS_DEFAULT_REGION
      - ecs-cli configure profile --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --profile-name $PROFILE_NAME
      - echo &quot;Updating the service...&quot;
      - ecs-cli up --capability-iam --size 1 --instance-type t2.medium --cluster-config $CONFIG_NAME --ecs-profile $PROFILE_NAME --force
      - ecs-cli compose --file ./docker-compose.prod.yml up --create-log-groups --cluster-config $CONFIG_NAME --ecs-profile $PROFILE_NAME --force-update
    only:
      - master
  
  </code></pre>
  <p>ecs-params.yml</p>
  <pre><code>version: 1
  task_definition:
    task_execution_role:
    services:
      proxy:
        essential: true
      api:
        essential: true
      worker:
        essential: true
  </code></pre>
  <p><a href="https://i.stack.imgur.com/HIeqY.png" rel="nofollow noreferrer">project structure</a></p>
  <p>I've attached configuration files.
  I think, I missed some AWS configurations, but I can't find mistakes.
  How can I fix it?</p>