1
votes

I have created a launch configuration which contains AWS CoreOS AMI as the image. This has been attached into AWS Auto Scaling Group. All the above process has been done via Terraform. But when Auto Scaling group tries to create the instance it fails with following error.

StatusMessage: "In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=ryg425ue2hwnsok9ccfastg4. Launching EC2 instance failed."

It seems like I have to Subscribe to use this CoreOS AMI image, but when I'm creating and instance on AS console, I just select the CoreOS image from market place and continue to other configurations related to instance. But how to achieve this in Terraform? Should I subscribe to AWS CoreOS AMI beforehand or is there a way to bypass this in Terraform?

All the related files and erro trace is given below,

launch-configuration.tf File

resource "aws_launch_configuration" "tomcat-webapps-all" {
  name                 = "tomcat-webapps-all"
  image_id             = "ami-028e043d0e518a84a"
  instance_type        = "t2.micro"
  key_name             = "rnf-sec"
  security_groups      = ["${aws_security_group.allow-multi-tomcat-webapp-traffic.id}"]
  user_data            = "${data.ignition_config.webapps.rendered}"
}

auto-scale-group.tf File

resource "aws_autoscaling_group" "tomcat-webapps-all-asg" {
  name                      = "tomcat-webapps-all-asg"
  depends_on                = ["aws_launch_configuration.tomcat-webapps-all"]
  vpc_zone_identifier       = ["${aws_default_subnet.default-az1.id}", "${aws_default_subnet.default-az2.id}", "${aws_default_subnet.default-az3.id}"]
  max_size                  = 1
  min_size                  = 0
  health_check_grace_period = 300
  health_check_type         = "EC2"
  desired_capacity          = 1
  force_delete              = true
  launch_configuration      = "${aws_launch_configuration.tomcat-webapps-all.id}"
  target_group_arns         = ["${aws_lb_target_group.newdasboard-lb-tg.arn}", "${aws_lb_target_group.signup-lb-tg.arn}"]
}

Error Trace

Error: Error applying plan:

1 error(s) occurred:

* aws_autoscaling_group.tomcat-webapps-all-asg: 1 error(s) occurred:

* aws_autoscaling_group.tomcat-webapps-all-asg: "tomcat-webapps-all-asg": Waiting up to 10m0s: Need at least 1 healthy instances in ASG, have 0. Most recent activity: {
  ActivityId: "9455ab55-426a-c888-ac95-2d45c78d445a",
  AutoScalingGroupName: "tomcat-webapps-all-asg",
  Cause: "At 2019-05-20T12:56:29Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1.",
  Description: "Launching a new EC2 instance.  Status Reason: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=ryg425ue2hwnsok9ccfastg4. Launching EC2 instance failed.",
  Details: "{\"Subnet ID\":\"subnet-c650458f\",\"Availability Zone\":\"ap-southeast-1a\"}",
  EndTime: 2019-05-20 12:56:30 +0000 UTC,
  Progress: 100,
  StartTime: 2019-05-20 12:56:30.642 +0000 UTC,
  StatusCode: "Failed",
  StatusMessage: "In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=ryg425ue2hwnsok9ccfastg4. Launching EC2 instance failed."
}
2

2 Answers

1
votes

If you log into the console and accept the ULA terms once this error will go away when you apply it via terraform.

If I was you I'd log in, go through the whole process to launch an instance with this AMI, terminate it, then apply the terraform.

0
votes

If somebody is also having the same issue, I was able to solve it by login into my EC2 console with root user and subscribing to AWS CoreOS Product Page on AWS Marketplace.

After that everything worked as expected. The error returned with a web URL to CoreOS product page on AWS Marketplace. Its just a matter of clicking Continue to Subscribe Button.

If above steps didn't work refer this answer - https://stackoverflow.com/a/56222898/4334340