Search code examples
amazon-web-servicesamazon-ecsamazon-cloudwatch

ECS, how to add user-data after creating ecs instance


I can't find a way to specify a user-data after creating ECS instance definition.

Document says You can pass this user data into the Amazon EC2 launch wizard in Step 6.g of Launching an Amazon ECS Container Instance.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bootstrap_container_instance.html#multi-part_user_data

ECS is launched automatically, how do you specify the user data?

I want to send /var/log/syslog to cloudwatch and I need to add user data (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_cloudwatch_logs.html)


Solution

  • I had to add the user data as a autoscaling group property

    steps are

    1. copy existing launch configuration
    2. edit user data of the launch configuration
    3. edit autoscaling group to use the created launch configuration
    4. terminate ecs instances so that the modified autoscaling group launches new ec2 with new launch configuration