Terraform-provider-aws: aws_launch_template with instance_market_options block causes ASG to error

Created on 5 Aug 2018  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.11.7
Provider aws version 1.30

Affected Resource(s)

aws_launch_template

when aws_launch_template includes

  instance_market_options {
    market_type = "spot"
    spot_options {
      spot_instance_type = "one-time"
    }
  }

This error is given:

* aws_autoscaling_group.default: 1 error(s) occurred:

* aws_autoscaling_group.default: Error creating AutoScaling Group: InvalidQueryParameter: Incompatible launch template: Auto Scaling only supports the 'one-time' Spot instance type with no duration.
        status code: 400, request id: b5c28b73-98ad-11e8-a1ce-e58004ec386d
bug documentation

All 4 comments

Hey! Thanks for writing in. I've verified this, unfortunately I can't find any documentation on AWS's documentation site that mentions it 😦

I think at this time we simply need to document it on both https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html and https://www.terraform.io/docs/providers/aws/r/launch_template.html#market-options . Adding a note on both pages to mention the limitation may be the best we can do for now.

Here's a full config that reproduces this, for those curious.:

resource "aws_launch_template" "foo" {
  name = "cts"

  block_device_mappings {
    device_name = "test"
  }

  credit_specification {
    cpu_credits = "standard"
  }

  disable_api_termination = true

  ebs_optimized = true

  elastic_gpu_specifications {
    type = "test"
  }

  iam_instance_profile {
    name = "test"
  }

  image_id = "ami-12a3b456"

  instance_initiated_shutdown_behavior = "terminate"

  instance_market_options {
    market_type = "spot"

    spot_options {
      spot_instance_type = "one-time"
    }
  }

  instance_type = "t2.micro"

  kernel_id = "aki-a12bc3de"

  key_name = "test"

  monitoring {
    enabled = true
  }

  network_interfaces {
    network_interface_id = "eni-123456ab"
    security_groups      = ["sg-1a23bc45"]
  }

  placement {
    availability_zone = "us-west-2b"
  }

  ram_disk_id = "ari-a12bc3de"

  vpc_security_group_ids = ["sg-12a3b45c"]

  tag_specifications {
    resource_type = "instance"

    tags {
      Name = "test"
    }
  }
}

resource "aws_autoscaling_group" "bar" {
  availability_zones        = ["us-west-2a"]
  name                      = "foobar3-terraform-test"
  max_size                  = 1
  min_size                  = 1
  health_check_grace_period = 300
  health_check_type         = "ELB"
  desired_capacity          = 0
  force_delete              = true

  termination_policies = [
    "ClosestToNextInstanceHour",
    "OldestLaunchConfiguration",
    "OldestInstance",
    "NewestInstance",
  ]

  launch_template = {
    id      = "${aws_launch_template.foo.id}"
    version = "$$Latest"
  }
}

The fix for this has been merged into master and will release with version 1.38.0 of the AWS provider, likely middle of this week.

This has been released in version 1.38.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings