Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_spot_instance_request fails when instance_interruption_behaviour is set to stop #2023

Closed
hashibot opened this issue Oct 24, 2017 · 7 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@hashibot
Copy link

This issue was originally opened by @kurron as hashicorp/terraform#16414. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.10.7

Terraform Configuration Files

resource "aws_spot_instance_request" "instance" {
    count = "${var.instance_limit > "0" ? var.instance_limit : length( var.subnet_ids )}"

    spot_price                      = "${var.spot_price}"
    wait_for_fulfillment            = "false"
    spot_type                       = "persistent"
    instance_interruption_behaviour = "${var.instance_interruption_behaviour}"
#   launch_group                    = "${var.launch_group}"

    ami                         = "${data.aws_ami.lookup.id}"
    ebs_optimized               = "${var.ebs_optimized}"
    instance_type               = "${var.instance_type}"
    key_name                    = "${var.ssh_key_name}"
    monitoring                  = true
    vpc_security_group_ids      = ["${var.security_group_ids}"]
    subnet_id                   = "${element( var.subnet_ids, count.index )}"
    iam_instance_profile        = "${var.instance_profile}"

    tags {
        Name        = "${format( "${var.name} %02d", count.index+1 )}"
        Project     = "${var.project}"
        Purpose     = "${var.purpose}"
        Creator     = "${var.creator}"
        Environment = "${var.environment}"
        Freetext    = "${var.freetext}"
        Scheduled   = "${var.scheduled}"
        Duty        = "${var.duty}"
    }
    volume_tags {
        Name        = "${format( "${var.name} %02d", count.index+1 )}"
        Project     = "${var.project}"
        Purpose     = "${var.purpose}"
        Creator     = "${var.creator}"
        Environment = "${var.environment}"
        Freetext    = "${var.freetext}"
    }
}

Debug Output

The log is large and can be found here. It appears that we are sending a Placement block in the JSON request when we might need to?

2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4: 2017/10/21 13:20:43 [DEBUG] Requesting spot bid opts: {
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:   InstanceCount: 1,
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:   InstanceInterruptionBehavior: "stop",
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:   LaunchSpecification: {
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     EbsOptimized: false,
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     IamInstanceProfile: {
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:       Name: "docker-2017101819084555130000000b"
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     },
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     ImageId: "ami-29f80351",
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     InstanceType: "m3.medium",
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     KeyName: "bastion-20171020163037962500000001",
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     Monitoring: {
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:       Enabled: true
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     },
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     NetworkInterfaces: [{
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:         DeviceIndex: 0,
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:         Groups: ["sg-9cdab5e1"],
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:         SubnetId: "subnet-568ee830"
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:       }],
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     Placement: {
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:       AvailabilityZone: "",
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:       GroupName: ""
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:     }
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:   },
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:   SpotPrice: "0.0670",
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4:   Type: "persistent"
2017-10-21T13:20:43.239-0400 [DEBUG] plugin.terraform-provider-aws_v1.1.0_x4: 

Crash Output

None.

Expected Behavior

I should be able to select a instance_interruption_behaviour to a value of stop without an error.

Actual Behavior

module.ec2_spot.aws_spot_instance_request.instance[2]: Creating...
ami: "" => "ami-29f80351"
associate_public_ip_address: "" => ""
availability_zone: "" => ""
ebs_block_device.#: "" => ""
ebs_optimized: "" => "false"
ephemeral_block_device.#: "" => ""
iam_instance_profile: "" => "docker-2017101819084555130000000b"
instance_interruption_behaviour: "" => "stop"
instance_state: "" => ""
instance_type: "" => "m3.medium"
ipv6_address_count: "" => ""
ipv6_addresses.#: "" => ""
key_name: "" => "bastion-20171020163037962500000001"
monitoring: "" => "true"
network_interface.#: "" => ""
network_interface_id: "" => ""
placement_group: "" => ""
primary_network_interface_id: "" => ""
private_dns: "" => ""
private_ip: "" => ""
public_dns: "" => ""
public_ip: "" => ""
root_block_device.#: "" => ""
security_groups.#: "" => ""
source_dest_check: "" => "true"
spot_bid_status: "" => ""
spot_instance_id: "" => ""
spot_price: "" => "0.0670"
spot_request_state: "" => ""
spot_type: "" => "persistent"
subnet_id: "" => "subnet-ac5f72f7"
tags.%: "" => "8"
tags.Creator: "" => "kurron@jvmguy.com"
tags.Duty: "" => "Docker"
tags.Environment: "" => "development"
tags.Freetext: "" => "No notes at this time."
tags.Name: "" => "Ultron 03"
tags.Project: "" => "Debug"
tags.Purpose: "" => "Runs Docker containers"
tags.Scheduled: "" => "Yes"
tenancy: "" => ""
volume_tags.%: "" => "6"
volume_tags.Creator: "" => "kurron@jvmguy.com"
volume_tags.Environment: "" => "development"
volume_tags.Freetext: "" => "No notes at this time."
volume_tags.Name: "" => "Ultron 03"
volume_tags.Project: "" => "Debug"
volume_tags.Purpose: "" => "Runs Docker containers"
vpc_security_group_ids.#: "" => "1"
vpc_security_group_ids.2717021527: "" => "sg-9cdab5e1"
wait_for_fulfillment: "" => "false"
Error applying plan:

3 error(s) occurred:

  • module.ec2_spot.aws_spot_instance_request.instance[1]: 1 error(s) occurred:

  • aws_spot_instance_request.instance.1: Error requesting spot instances: InvalidParameterCombination: The parameter GroupName within placement information cannot be specified when instanceInterruptionBehavior is set to 'stop'.
    status code: 400, request id: 4d0aa070-41ed-4ce0-aa38-f623b35f9e67

  • module.ec2_spot.aws_spot_instance_request.instance[0]: 1 error(s) occurred:

  • aws_spot_instance_request.instance.0: Error requesting spot instances: InvalidParameterCombination: The parameter GroupName within placement information cannot be specified when instanceInterruptionBehavior is set to 'stop'.
    status code: 400, request id: f04661d5-0324-47f5-97ca-68ad0d1c0bc9

  • module.ec2_spot.aws_spot_instance_request.instance[2]: 1 error(s) occurred:

  • aws_spot_instance_request.instance.2: Error requesting spot instances: InvalidParameterCombination: The parameter GroupName within placement information cannot be specified when instanceInterruptionBehavior is set to 'stop'.
    status code: 400, request id: 1cca1b36-19f6-4403-b676-6a0902135545

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Steps to Reproduce

  1. git clone https://github.com/kurron/terraform-aws-ec2-spot.git
  2. debug/debug-module.sh
  3. edit debug/plan.tf to use different values

Important Factoids

Same plan but using a value of terminate works. I wonder if we are sending placement information we don't need to. I am specifying the subnets, which are available in all AZs, to install to.

References

I could not find any.

@nonsense
Copy link

This is still happening with Terraform v0.11.2 and both provider.aws v1.6.0 and provider.aws v1.5.0.

@radeksimko radeksimko added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jan 28, 2018
@Klintrup
Copy link

also happening with terraform 0.11.2 and provider 1.9.0

@whitechdevs
Copy link

Still happening with Terraform v0.11.3 and provider.aws v1.10.0

@ntman4real
Copy link

Still happening with Terraform v0.11.5 and provider.aws v1.14.70

@billyfoss
Copy link

I found the code from PR 1986 is working well for my usage.
#1986
I have merged that into my fork and added the hibernate option, but I have not tested 'hibernate' yet.

@bflad
Copy link
Contributor

bflad commented Jan 4, 2019

Sorry for missing this earlier folks, but it looks like the fix for this was previously released awhile ago in version 1.15.0 of the AWS provider and has been available in all releases since. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

Two other notes:

  • If you are still having trouble with this, please open a new bug report issue with all the issue template details so we can take a fresh look
  • The instance_interruption_behaviour argument name will likely be fixed to instance_interruption_behavior in version 2.0.0 of the Terraform AWS provider, see also Rename instance_interruption_behaviour attribute in v2.0.0 #7006

@bflad bflad closed this as completed Jan 4, 2019
@bflad bflad added this to the v1.15.0 milestone Jan 4, 2019
@ghost
Copy link

ghost commented Apr 1, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

8 participants