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

r/launch_template: fix market options #5957

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

kl4w
Copy link
Contributor

@kl4w kl4w commented Sep 21, 2018

Fixes #5455

Changes proposed in this pull request:

  • only set market option attributes when present

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSLaunchTemplate_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSLaunchTemplate_ -timeout 120m
=== RUN   TestAccAWSLaunchTemplate_importBasic
--- PASS: TestAccAWSLaunchTemplate_importBasic (13.66s)
=== RUN   TestAccAWSLaunchTemplate_importData
--- PASS: TestAccAWSLaunchTemplate_importData (11.91s)
=== RUN   TestAccAWSLaunchTemplate_basic
--- PASS: TestAccAWSLaunchTemplate_basic (13.62s)
=== RUN   TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (48.81s)
=== RUN   TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS_DeleteOnTermination
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS_DeleteOnTermination (49.03s)
=== RUN   TestAccAWSLaunchTemplate_data
--- PASS: TestAccAWSLaunchTemplate_data (11.93s)
=== RUN   TestAccAWSLaunchTemplate_update
--- PASS: TestAccAWSLaunchTemplate_update (45.77s)
=== RUN   TestAccAWSLaunchTemplate_tags
--- PASS: TestAccAWSLaunchTemplate_tags (21.27s)
=== RUN   TestAccAWSLaunchTemplate_creditSpecification_nonBurstable
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_nonBurstable (11.76s)
=== RUN   TestAccAWSLaunchTemplate_creditSpecification_t2
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t2 (10.47s)
=== RUN   TestAccAWSLaunchTemplate_creditSpecification_t3
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t3 (12.16s)
=== RUN   TestAccAWSLaunchTemplate_networkInterface
--- PASS: TestAccAWSLaunchTemplate_networkInterface (29.96s)
=== RUN   TestAccAWSLaunchTemplate_networkInterface_ipv6Addresses
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6Addresses (11.00s)
=== RUN   TestAccAWSLaunchTemplate_networkInterface_ipv6AddressCount
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6AddressCount (11.95s)
=== RUN   TestAccAWSLaunchTemplate_instanceMarketOptions
--- PASS: TestAccAWSLaunchTemplate_instanceMarketOptions (47.13s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	350.492s

@ghost ghost added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Sep 21, 2018
@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. labels Sep 24, 2018
@bflad bflad added this to the v1.38.0 milestone Sep 24, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @kl4w! 🚀

15 tests passed (all tests)
--- PASS: TestAccAWSLaunchTemplate_basic (4.97s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_nonBurstable (5.00s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6Addresses (5.05s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t3 (6.13s)
--- PASS: TestAccAWSLaunchTemplate_importBasic (7.09s)
--- PASS: TestAccAWSLaunchTemplate_data (7.33s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t2 (7.45s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6AddressCount (7.54s)
--- PASS: TestAccAWSLaunchTemplate_importData (8.22s)
--- PASS: TestAccAWSLaunchTemplate_tags (11.59s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface (12.14s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (37.69s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS_DeleteOnTermination (42.28s)
--- PASS: TestAccAWSLaunchTemplate_update (63.81s)
--- PASS: TestAccAWSLaunchTemplate_instanceMarketOptions (73.76s)

@bflad bflad merged commit dd8ca08 into hashicorp:master Sep 24, 2018
bflad added a commit that referenced this pull request Sep 24, 2018
@kl4w kl4w deleted the launch-template-market-options branch September 25, 2018 13:04
@bflad
Copy link
Contributor

bflad commented Sep 26, 2018

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.

@timonwalkley
Copy link

After updating we're still experiencing the Auto Scaling only supports the 'one-time' Spot instance type with no duration error when defining instance_market_options.

Terraform version 0.11.8
AWS Provider version 1.38.0

  instance_market_options {
    market_type = "spot"

    spot_options {
      max_price          = "10"
      spot_instance_type = "one-time"
    }
  }

@kl4w
Copy link
Contributor Author

kl4w commented Sep 27, 2018

@timonwalkley is this a previously created launch template or a new resource?

I can't seem to repro this after updating. Using this config:

resource aws_launch_template test {
  name_prefix = "test"
  image_id    = "ami-a9d09ed1"

  instance_type = "t2.micro"

  instance_market_options {
    market_type = "spot"

    spot_options {
      max_price          = "10"
      spot_instance_type = "one-time"
    }
  }
}

resource aws_vpc test {
  cidr_block = "10.1.0.0/16"
}

resource aws_subnet test {
  vpc_id     = "${aws_vpc.test.id}"
  cidr_block = "10.1.0.0/24"
}

resource aws_autoscaling_group test {
  name_prefix = "test"

  launch_template {
    name    = "${aws_launch_template.test.name}"
    version = "${aws_launch_template.test.latest_version}"
  }

  vpc_zone_identifier = ["${aws_subnet.test.id}"]
  min_size            = 0
  max_size            = 1
  desired_capacity    = 0
}

I get:

terraform apply -auto-approve
aws_vpc.test: Creating...
  arn:                              "" => "<computed>"
  assign_generated_ipv6_cidr_block: "" => "false"
  cidr_block:                       "" => "10.1.0.0/16"
  default_network_acl_id:           "" => "<computed>"
  default_route_table_id:           "" => "<computed>"
  default_security_group_id:        "" => "<computed>"
  dhcp_options_id:                  "" => "<computed>"
  enable_classiclink:               "" => "<computed>"
  enable_classiclink_dns_support:   "" => "<computed>"
  enable_dns_hostnames:             "" => "<computed>"
  enable_dns_support:               "" => "true"
  instance_tenancy:                 "" => "default"
  ipv6_association_id:              "" => "<computed>"
  ipv6_cidr_block:                  "" => "<computed>"
  main_route_table_id:              "" => "<computed>"
aws_launch_template.test: Creating...
  arn:                                                         "" => "<computed>"
  default_version:                                             "" => "<computed>"
  image_id:                                                    "" => "ami-a9d09ed1"
  instance_market_options.#:                                   "" => "1"
  instance_market_options.0.market_type:                       "" => "spot"
  instance_market_options.0.spot_options.#:                    "" => "1"
  instance_market_options.0.spot_options.0.max_price:          "" => "10"
  instance_market_options.0.spot_options.0.spot_instance_type: "" => "one-time"
  instance_market_options.0.spot_options.0.valid_until:        "" => "<computed>"
  instance_type:                                               "" => "t2.micro"
  latest_version:                                              "" => "<computed>"
  name:                                                        "" => "<computed>"
  name_prefix:                                                 "" => "test"
aws_launch_template.test: Creation complete after 1s (ID: lt-03dc7f8b50008b5ed)
aws_vpc.test: Creation complete after 5s (ID: vpc-0383d6dffd0fef340)
aws_subnet.test: Creating...
  arn:                             "" => "<computed>"
  assign_ipv6_address_on_creation: "" => "false"
  availability_zone:               "" => "<computed>"
  cidr_block:                      "" => "10.1.0.0/24"
  ipv6_cidr_block:                 "" => "<computed>"
  ipv6_cidr_block_association_id:  "" => "<computed>"
  map_public_ip_on_launch:         "" => "false"
  vpc_id:                          "" => "vpc-0383d6dffd0fef340"
aws_subnet.test: Creation complete after 2s (ID: subnet-0a35cf1aa75aaca1f)
aws_autoscaling_group.test: Creating...
  arn:                            "" => "<computed>"
  default_cooldown:               "" => "<computed>"
  desired_capacity:               "" => "0"
  force_delete:                   "" => "false"
  health_check_grace_period:      "" => "300"
  health_check_type:              "" => "<computed>"
  launch_template.#:              "" => "1"
  launch_template.0.id:           "" => "<computed>"
  launch_template.0.name:         "" => "test20180927130213270900000001"
  launch_template.0.version:      "" => "1"
  load_balancers.#:               "" => "<computed>"
  max_size:                       "" => "1"
  metrics_granularity:            "" => "1Minute"
  min_size:                       "" => "0"
  name:                           "" => "<computed>"
  name_prefix:                    "" => "test"
  protect_from_scale_in:          "" => "false"
  service_linked_role_arn:        "" => "<computed>"
  target_group_arns.#:            "" => "<computed>"
  vpc_zone_identifier.#:          "" => "1"
  vpc_zone_identifier.2184579090: "" => "subnet-0a35cf1aa75aaca1f"
  wait_for_capacity_timeout:      "" => "10m"
aws_autoscaling_group.test: Creation complete after 3s (ID: test20180927130219966600000003)

Apply complete! Resources: 4 added, 0 changed, 0 destroyed.

@timonwalkley
Copy link

Hi @kl4w, this was with a previously created launch template. Deleting the launch template and recreating it has resolved the issue. I've tried to repo the issue but I'm not able to either.

@ghost
Copy link

ghost commented Apr 3, 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 3, 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. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_launch_template with instance_market_options block causes ASG to error
3 participants