Terraform 0.12.2 / AWS / EKS / Hashicorp Tutorial

Hi,

I am using terraform for personal and professional projects and i am very pleased with this tool, but i just encounter a problem, and don’t really know how to fix it. It might be related to my TF version (0.12.2), or recent modifications in those two modules : aws_launch_configuration and aws_autoscaling_group.

I am following Hashicorp tutorial at : https://learn.hashicorp.com/terraform/aws/eks-intro to deploy a kubernetes cluster using TF & EKS.

As it is testing i didn’t change any values from the tutorial, i am just running it as it is to check results.

When it comes to this part :

resource "aws_launch_configuration" "demo" {
  associate_public_ip_address = true
  iam_instance_profile        = "${aws_iam_instance_profile.demo-node.name}"
  image_id                    = "${data.aws_ami.eks-worker.id}"
  instance_type               = "m4.large"
  name_prefix                 = "terraform-eks-demo"
  security_groups             = ["${aws_security_group.demo-node.id}"]
  user_data_base64            = "${base64encode(local.demo-node-userdata)}"

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_autoscaling_group" "demo" {
  desired_capacity     = 2
  launch_configuration = "${aws_launch_configuration.demo.id}"
  max_size             = 2
  min_size             = 1
  name                 = "terraform-eks-demo"
  vpc_zone_identifier  = "${aws_subnet.demo.*.id}"

  tag {
    key                 = "Name"
    value               = "terraform-eks-demo"
    propagate_at_launch = true
  }

  tag {
    key                 = "kubernetes.io/cluster/${var.cluster-name}"
    value               = "owned"
    propagate_at_launch = true
  }
}

Instances are not created within the autoscaling group, and TF has a timeout after 10 min, showing this error :

Error: "terraform-eks-demo": Waiting up to 10m0s: Need at least 2 healthy instances in ASG, have 0. Most recent activity: {
  ActivityId: "b085af05-d757-60e7-0f69-00e81ae68231",
  AutoScalingGroupName: "terraform-eks-demo",
  Cause: "At 2019-07-05T09:27:32Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 2.",
  Description: "Launching a new EC2 instance.  Status Reason: The requested configuration is currently not supported. Please check the documentation for supported configurations. Launching EC2 instance failed.",
  Details: "{\"Subnet ID\":\"subnet-008d31689c4769de7\",\"Availability Zone\":\"eu-west-3b\"}",
  EndTime: 2019-07-05 09:27:33 +0000 UTC,
  Progress: 100,
  StartTime: 2019-07-05 09:27:33.592 +0000 UTC,
  StatusCode: "Failed",
  StatusMessage: "The requested configuration is currently not supported. Please check the documentation for supported configurations. Launching EC2 instance failed."
}

I read the documentation of the two modules aws_launch_configuration & aws_autoscaling_group but couldn’t find where the problem is coming from.

Any help appreciated !

Thanks,

Regards,

I am going to make a wild guess here that EC2 type m4.nnnnn may not be available in eu-west-3b. Could you try changing m4 to m5 and see if that works?

If that is not the case, could you try fixing the Availability Zone to “a”, maybe its available there ?!?

1 Like

Your wild guess was perfectly correct, thx !

1 Like