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]: Changes to docker_volume_configuration block in aws_ecs_task_definition resource are not detected #40801

Closed
mmigliari opened this issue Jan 7, 2025 · 4 comments · Fixed by #40853
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service.
Milestone

Comments

@mmigliari
Copy link

mmigliari commented Jan 7, 2025

Terraform Core Version

1.10.3

AWS Provider Version

5.82.2

Affected Resource(s)

docker_volume_configuration block within a dynamic volume block in an aws_ecs_task_definition resource

Description

Changes to the docker_volume_configuration block in an aws_ecs_task_definition resource are not detected by Terraform unless the resource is removed from state first. This appears to be an issue with how the provider compares the volume configuration.

Reproduction Case

The task definition module uses a dynamic volume block based on an EFS configuration:

Steps to Reproduce

  1. Change the timeo value in the volume block from 600 to 500
  2. Run terraform plan on the configuration below
  3. No changes are detected

Expected Behavior

Terraform should detect changes to the volume configuration and create a new task definition revision when such changes are made.

Actual Behavior

Terraform does not detect changes to the volume configuration unless the resource is removed from state first.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_ecs_task_definition" "this" {
  for_each = {
    for td in var.task_definitions : td.family => td
  }

  family = "${var.cluster_name}-${var.environment}-${each.key}"
  container_definitions = templatefile(each.value.container_definitions, {
    environment        = var.environment
    cluster_name       = var.cluster_name
    image_name         = each.value.family
    max_memory         = each.value.replica_max_memory
    memory_reservation = each.value.replica_memory_reservation
    max_cpu            = each.value.replica_max_cpu
  })

  task_role_arn            = var.task_role_arn
  execution_role_arn       = var.task_execution_role_arn
  requires_compatibilities = ["EC2"]
  cpu                      = each.value.total_cpu
  memory                   = each.value.total_memory
  
dynamic "volume" {
    for_each = contains(keys(local.taskdefs_with_efs), each.key) ? [local.taskdefs_with_efs[each.key]] : []
    content {
      name = "data"
      
     docker_volume_configuration {
        autoprovision = false
        driver        = "local"
        driver_opts = {
          device = "example-${var.environment}-efs.internal:/"
          o      = "addr=example-${var.environment}-efs.internal,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"
          type   = "nfs"
        }
        scope = "task"
      }
    }
  }
}

The task definitions are defined in variables:

variable "task_definitions" {
  type = list(object({
    family                     = string
    container_definitions      = string
    total_cpu                  = number
    total_memory               = number
    replica_max_memory         = number
    replica_memory_reservation = number
    replica_max_cpu            = number
    efs_configuration = object({
      private_hosted_zone = string
    })
  }))
}

Steps to Reproduce

  1. Apply the above configuration
  2. Change the timeo value in the volume configuration from 600 to 500
  3. Run terraform plan - no changes are detected
@mmigliari mmigliari added the bug Addresses a defect in current functionality. label Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

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 service/ecs Issues and PRs that pertain to the ecs service. needs-triage Waiting for first response or review from a maintainer. labels Jan 7, 2025
@mmigliari mmigliari changed the title [Bug]: Changes to docker_volume_configuration block in aws_ecs_task_definition resource are not detected [Bug]: Changes to docker_volume_configuration block in aws_ecs_task_definition resource are not detected Jan 7, 2025
@mmigliari
Copy link
Author

mmigliari commented Jan 7, 2025

Similar issues:

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jan 8, 2025
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.84.0 milestone Jan 10, 2025
Copy link

This functionality has been released in v5.84.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

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/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants