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

[Bug]: Increase of root volume size of AMI in launch template block_device_mapping does not work on arm64 instances but on x86_64 #37559

Open
sstoefe opened this issue May 16, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@sstoefe
Copy link

sstoefe commented May 16, 2024

Terraform Core Version

1.8.2

AWS Provider Version

5.47.0

Affected Resource(s)

  • aws_launch_template
  • aws_ec2_fleet

Expected Behavior

When I spawn an ec2 x86_64 instance (in this case it was m5zn.metal) via EC2 Fleet API and increase the root volume size via block_device_mapping block inside the aws_launch_template the actual device and partitions are enlarged and work as expected:

image

A default ubuntu 20.04 server AMI (x86_64) was used here. By default the AMI has a volume_size of 8GB. With the block_device_mapping is is increased to 40GB.

When I spawn an arm64 instance (c7g.metal) I expect the same behaviour. Also ubuntu server 20.04 AMI (arm64) is used. By default the AMI has a volume_size of 8GB.

Actual Behavior

However, when I spawn an arm64 instance (c7g.metal) I see that the actual volume is enlarged but the partition is not. There I have to increase the filesystem manually (see https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-linux.html):

image image

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

# Fetch latest ubuntu AMI
data "aws_ami" "ubuntu_ami" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/*ubuntu-focal-20.04-${var.cpu_architecture == "x86_64" ? "amd64" : "arm64"}-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  filter {
    name   = "architecture"
    values = ["${var.cpu_architecture}"]
  }

  owners = ["099720109477"] # Canonical
}

locals {
  allowed_instance_types    = var.cpu_architecture == "x86_64" ? var.spot_instances_x86_64 : var.spot_instances_arm64
  on_demand_target_capacity = var.cpu_architecture == "x86_64" ? 0 : 1
  spot_target_capacity      = var.cpu_architecture == "x86_64" ? 1 : 0
}

# launch template for EC2 fleet API
resource "aws_launch_template" "launch_template" {
  block_device_mappings {
    device_name = data.aws_ami.ubuntu_ami.root_device_name

    ebs {
      volume_size = 40
    }
  }
  ...
}

# EC2 fleet request
resource "aws_ec2_fleet" "instance" {
  launch_template_config {
    launch_template_specification {
      launch_template_id = aws_launch_template.launch_template.id
      version                      = aws_launch_template.launch_template.latest_version
    }
  }

  target_capacity_specification {
    default_target_capacity_type = "spot"
    on_demand_target_capacity    = local.on_demand_target_capacity
    spot_target_capacity         = local.spot_target_capacity
    total_target_capacity        = 1
  }

  on_demand_options {
    allocation_strategy      = "lowestPrice"
    single_availability_zone = true
    min_target_capacity      = local.on_demand_target_capacity
  }

  spot_options {
    allocation_strategy = "price-capacity-optimized"
  }

  terminate_instances = true

  type = "instant"
}

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. login to arm64 instance and check volume size

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@sstoefe sstoefe added the bug Addresses a defect in current functionality. label May 16, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/ec2 Issues and PRs that pertain to the ec2 service. label May 16, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 16, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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

2 participants