terraform-aws-modules / terraform-aws-ec2-instance

Terraform module to create AWS EC2 instance(s) resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws
Apache License 2.0
758 stars 1.88k forks source link

Cannot change the size of attached EBS volume #279

Closed dstkdevhrp closed 2 years ago

dstkdevhrp commented 2 years ago

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

Terraform v1.2.1 on darwin_amd64

Reproduction Code [Required]

module "instances_ha_cluster" {
  source  = "terraform-aws-modules/ec2-instance/aws"
  version = "~> 4.0"

  name                        = instance_test
  ami                         = ami-073770dc3242b2a06 // AWS ap-northeast-1 tokyo
  instance_type               = m6i.large
  subnet_id                   = default_subnet // should be one in your test env
  vpc_security_group_ids      = default_security_group // should be one in your test env
  associate_public_ip_address = false
  // key_name                    = random_pet.this.id // can be ignored, not related to the bug
  source_dest_check           = false  # for Calico network
  root_block_device = [
    {
      encrypted   = false
      volume_type = "gp3"
      volume_size = 16
    },
  ]
  ebs_block_device = [
    {
      device_name = "/dev/sdf"
      volume_type = "gp3"
      volume_size = 96 // Bug related to this param, after created, no matter which number it's changed to, Terraform always say 'no changes needed ...'
      encrypted   = false
    }
  ]
  monitoring                  = true
  // iam_instance_profile        = data.aws_iam_instance_profile.aiip_ecr_read.name // ignored
  // tags                        = local.tags_cluster // ignored
}

Steps to reproduce the behavior:

No Yes
  1. Run the code copied above, we can got an ec2 instance created in AWS.
  2. Change the value of 'volume_size' param in node 'ebs_block_device', Terraform didn't notice it and didn't proceed the change.

Expected behavior

I hope Terraform can update the volume size of the extra ebs volume of the ec2 instance.

Actual behavior

No matter which number it's changed to, Terraform always say 'no changes needed ...'

Terminal Output Screenshot(s)

Screen Shot 2022-07-19 at 9 05 28 AM

Thanks for your product and the support!

ravindrasinghh commented 2 years ago

Hi dstkdevhrp, You can use below configuration to increase root disk size,It is working for me. data "aws_kms_key" "ebs" { key_id = "alias/aws/ebs" } root_block_device = [ { delete_on_termination = true encrypted = true kms_key_id = data.aws_kms_key.ebs.arn volume_size = 200 volume_type = "gp2" tags = { Created_using_terraform = true } } ]

github-actions[bot] commented 2 years 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 2 years ago

This issue was automatically closed because of stale in 10 days

Udbv commented 2 years ago

I have the same issue - changes in the ebs_block_device object produces no changes

github-actions[bot] commented 2 years 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.