terraform-aws-modules / terraform-aws-autoscaling

Terraform module to create AWS Auto Scaling resources πŸ‡ΊπŸ‡¦
https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws
Apache License 2.0
292 stars 557 forks source link

v7.7.0 An argument named "max_spot_price_as_percentage_of_optimal_on_demand_price" is not expected here. #277

Closed orcutt989 closed 1 month ago

orcutt989 commented 3 months ago

Description

Standing up an instance without instance_market_options appears to perhaps be broken.

Seems like new max_spot_price_as_percentage_of_optimal_on_demand_price functionality may be broken if you want on demand. in 7.7.0.

7.6.1 works fine with instance_market_options omitted.

Versions

Terraform v1.8.4 on darwin_arm64 provider registry.terraform.io/hashicorp/aws v5.52.0

Reproduction Code [Required]

terragrunt.hcl

terraform {
  source = "git::https://github.com/terraform-aws-modules/terraform-aws-autoscaling.git//.?ref=v7.7.0"
}

inputs = {
  name = "${local.environment}-${local.name}-ec2-instance" # TODO: fill in value

  # ASG
  create                    = true
  min_size                  = 1
  max_size                  = 1
  desired_capacity          = 1
  desired_capacity_type     = "units"
  health_check_type         = "EC2"
  health_check_grace_period = 600
  vpc_zone_identifier       = dependency.vpc.outputs.vpc_private_subnets
  service_linked_role_arn   = "arn:aws:iam::${local.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling_CMK"
  wait_for_capacity_timeout = "2m"

  security_groups = [
    dependency.sg.outputs.security_group_arn
  ]

  # User Data
  user_data          = filebase64("./userdata.sh"),

  # Launch template
  create_launch_template      = true
  launch_template_name        = "${local.environment}-${local.name}-lt"
  launch_template_description = "Launch template for ${local.environment}-${local.name}"
  launch_template_version     = "$Latest"
  update_default_version      = true

  image_id          = "ami-0f96c63e39f9144bc"
  instance_type     = "t3a.medium"
  ebs_optimized     = true
  enable_monitoring = true

  # IAM role & instance profile
  create_iam_instance_profile = true
  iam_role_name               = "${local.environment}-${local.name}-iam-role"
  iam_role_policies = {
    InstancePolicy = dependency.instance_policy.outputs.policy_arn
  }

  block_device_mappings = [
    {
      device_name = "/dev/xvda"
      ebs = {
        volume_size = 8
        encrypted   = true,
        kms_key_id  = dependency.ebs-kms.outputs.key_arn
      }
    }
  ]

  metadata_options = {
    http_endpoint               = "enabled"
    http_tokens                 = "required"
    http_put_response_hop_limit = 1
  }

  tag_specifications = [
    for service in local.services : {
      resource_type = lower(service)
      tags = merge(local.tags, {
        service = service
      })
    }
  ]
}

Steps to reproduce the behavior:

Expected behavior

No errors when instance_market_options is omitted as in version 7.6.1

Actual behavior

β•·
β”‚ Error: Unsupported argument
β”‚
β”‚   on main.tf line 199, in resource "aws_launch_template" "this":
β”‚  199:       max_spot_price_as_percentage_of_optimal_on_demand_price = try(instance_requirements.value.max_spot_price_as_percentage_of_optimal_on_demand_price, null)
β”‚
β”‚ An argument named "max_spot_price_as_percentage_of_optimal_on_demand_price"
β”‚ is not expected here.
β•΅
ERRO[0009] terraform invocation failed in ~/infrastructure/project/path/ec2/.terragrunt-cache/ruXNvyV7SznSTNOk-8wi93g0xhQ/dPPhkSsmCIviPsfd_W6bpUQ1VNM  prefix=[~/infrastructure/project/path/ec2]
INFO[0009] Shutting down Terragrunt Cache server...
INFO[0009] Terragrunt Cache server stopped
ERRO[0009] 1 error occurred:
    * [~/infrastructure/project/path/ec2/.terragrunt-cache/ruXNvyV7SznSTNOk-8wi93g0xhQ/dPPhkSsmCIviPsfd_W6bpUQ1VNM] exit status 1

Terminal Output Screenshot(s)

Additional context

I've tried the following including omitting instance_market_options :

  instance_market_options = null
  instance_market_options = {
    market_type = "ondemand"
  }
  instance_market_options = {
    market_type = null
  }
github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 month ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 3 weeks ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.