How can I connect my autoscaling group to my ecs cluster?

前端 未结 3 744
独厮守ぢ
独厮守ぢ 2021-01-31 02:52

In all tutorials for ECS you need to create a cluster and after that an autoscaling group, that will spawn instances. Somehow in all these tutorials the instances magically show

3条回答
  •  长发绾君心
    2021-01-31 03:16

    Well, i found out. Its all about the ecs-agent and its config file /etc/ecs/ecs.config (This file will be created through the Userdata field, when creating EC2 instances, even from an autoscaling configuration.) Read about its configuration options here: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html

    But you can even copy a ecs.config stored on Amazon S3, do it like this (following lines go into Userdata field):

    #!/bin/bash
    yum install -y aws-cli
    aws configure set default.s3.signature_version s3v4
    aws configure set default.s3.addressing_style path
    aws configure set default.region eu-central-1
    aws s3 cp s3:///ecs.config /etc/ecs/ecs.config
    

    note: Signature_version v4 is specific for some regions, like eu-central-1. This ofc only works, if your IAM role for the instance (in my case its ecsInstanceRole) has the right AmazonS3ReadOnlyAccess


    The AWS GUI console way for that would be: Use the cluster wizard at https://console.aws.amazon.com/ecs/home#/firstRun . It will create an autoscaling grou for your cluster, a loadbalancer in front of it, and connect it all nicely.

提交回复
热议问题