How to add launch type to an ecs service from ecs-cli?

0

I'm deploying a service to an ecs from ecs-cli, but I couldn't find any attribute to specify the value of "LAUNCH TYPE" to use "capacity provider strategy". default is set to EC2. Is it possible to do it from ecs-cli or some attribute in the yml file or ecs-params?

docker-compose.yml


version: '3'
services:
  task_auth:
    environment:
      AWS_API_VERSION: "2016-04-19"
      AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /creds
      BACKURL: http://XXXXXXX
    image: XXXX.dkr.ecr.us-east-1.amazonaws.com/XXXXXX
    ports:
      - "8004:8000"
    logging:
      driver: awslogs
      options:
        awslogs-group: logscompose
        awslogs-region: us-east-1
        awslogs-stream-prefix: auth


ecs-params.yml


version: '3'
services:
  task_auth:
    environment:
      AWS_API_VERSION: "2016-04-19"
      AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /creds
      BACKURL: http://XXXXXXX
    image: XXXX.dkr.ecr.us-east-1.amazonaws.com/XXXXXX
    ports:
      - "8004:8000"
    logging:
      driver: awslogs
      options:
        awslogs-group: logscompose
        awslogs-region: us-east-1
        awslogs-stream-prefix: auth

Result

Enter image description here

Enter image description here

asked 2 years ago754 views
2 Answers
0

Please take a look at https://github.com/aws/amazon-ecs-cli

It mentions the following

**ECS now offers two different launch types for tasks and services: EC2 and FARGATE. With the FARGATE launch type, customers no longer have to manage their own container-instances.

In the ECS-CLI, you can specify either launch type when you bring up a cluster using the --launch-type flag (see: Creating an ECS Cluster). You can also configure your cluster to use a particular launch type with the --default-launch-type flag (see: Cluster Configurations).

You can also specify which launch type to use for a task or service in compose up or compose service up, regardless of which launch type is configured for your cluster (see: Starting/Running Tasks).**

profile pictureAWS
EXPERT
answered 2 years ago
0

I referred the documentation [1] to check whether we can change the value of "LAUNCH TYPE" to use "capacity provider strategy” while deploying a service. According to the doc[1] by using --default-launch-type to your cluster configuration we can set the launch type to EC2 or FARGATE. But there is no mention of using "capacity provider strategy”.

I went ahead and checked the similar use case AWS Command Line Interface (AWS CLI). The AWS Command Line Interface (AWS CLI) is a unified client for AWS services that provides commands for all public API operations. These commands are lower level than those provided by the Amazon ECS CLI. Using the AWS CLI commands we can configure the “--capacity-provider-strategy” attribute while creating the cluster [2].

The details of a capacity provider strategy. A capacity provider strategy can be set when using the RunTask or CreateCluster APIs or as the default capacity provider strategy for a cluster with the CreateCluster API. Only capacity providers that are already associated with a cluster and have an ACTIVE or UPDATING status can be used in a capacity provider strategy. The PutClusterCapacityProviders API is used to associate a capacity provider with a cluster. If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New Auto Scaling group capacity providers can be created with the CreateCapacityProvider API operation.

You can check more details details related to this in the documentation[2].

Reference: [1] https://github.com/aws/amazon-ecs-cli#amazon-ecs-cli-commands [2] https://docs.aws.amazon.com/cli/latest/reference/ecs/create-service.html [3] https://docs.aws.amazon.com/cli/latest/reference/ecs/update-service.html [4] https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/put-cluster-capacity-providers.html

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions