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 556 forks source link

block_device_mappings does not support different types together (e.g. EBS and ephemeral) #222

Closed Evisort-Dave closed 1 year ago

Evisort-Dave commented 1 year ago

Description

As the type of the block_device_mappings is currently set to list(any), this prevents you from being able to specify e.g. an EBS volume (which requires an ebs {} configuration block), as well as an instance store volume (which requires the virtual_name attribute), as the object structure of each list item will not match and this will fail Terraform's type checking.

Versions

Reproduction Code [Required]

  block_device_mappings = [
    {
      # Root EBS volume
      device_name = "/dev/xvda"
      ebs = {
        delete_on_termination = true
        encrypted = true
        volume_size = 40
        volume_type = "gp2"
      }
    },
    {
      # Local instance store
      device_name = "/dev/xvdb"
      virtual_name = "ephemeral0"
    }
  ]

Steps to reproduce the behavior:

Create an ASG with the above block_device_mappings config.

Expected behavior

The configuration allows me to specify a launch template with both an EBS volume and an instance store volume on the same instance.

Actual behavior

The above configuration will fail with the error all list elements must have the same type.

Additional context

I'm not able to find a workaround here, as I can't make the elements match by e.g. adding virtual_name = null to the EBS element, as it won't match the string type of the second element, and if I set it to a blank string, the provider crashes.

Any ideas?

bryantbiggs commented 1 year ago

There is no effect on having an ephemeral instance store listed in the block device mappings. Either they are present based on the instance type or they are not. To utilize, you will need to mount them, typically through user data

github-actions[bot] commented 1 year 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 year 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.