DEV Community

Sergey Zhekpisov
Sergey Zhekpisov

Posted on

Bottlerocket OS and ECS

When you run your ECS on Bottlerocket OS images, make sure that your user data is configured correctly.

❌ Wrong way:

module "autoscaling" {
  source  = "terraform-aws-modules/autoscaling/aws"
  version = "8.3.0"

  for_each = {
    # On-demand instances
    ex_1 = {
      instance_type              = t3.micro
      user_data                  = <<-EOT
        #!/bin/bash
        cat <<'EOF' >> user-data.toml
        [settings.ecs]
        cluster = "ecs-cluster"
        EOF
      EOT
    }
  }
Enter fullscreen mode Exit fullscreen mode

✅ Right way:

module "autoscaling" {
  source  = "terraform-aws-modules/autoscaling/aws"
  version = "8.3.0"

  for_each = {
    # On-demand instances
    ex_1 = {
      instance_type              = t3.micro
      user_data                  = <<-EOT
      [settings.ecs]
      cluster = "ecs-cluster"
      EOT
    }
  }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)