Skip to content

tfautomv fails to find move for aws_sqs_queue #53

@FalconerTC

Description

@FalconerTC

Hello! I like this project and would like to give some data to help improve it. There's a scenario where I'd like to be able to use tfautomv.

  # aws_sqs_queue.backup_queues["statstracking-v3-test-notification-backup"] will be created
  + resource "aws_sqs_queue" "backup_queues" {
      + arn                               = (known after apply)
      + content_based_deduplication       = false
      + deduplication_scope               = (known after apply)
      + delay_seconds                     = 0
      + fifo_queue                        = false
      + fifo_throughput_limit             = (known after apply)
      + id                                = (known after apply)
      + kms_data_key_reuse_period_seconds = (known after apply)
      + max_message_size                  = 262144
      + message_retention_seconds         = 1209600
      + name                              = "statstracking-v3-test-notification-backup"
      + name_prefix                       = (known after apply)
      + policy                            = (known after apply)
      + receive_wait_time_seconds         = 0
      + redrive_allow_policy              = (known after apply)
      + redrive_policy                    = (known after apply)
      + sqs_managed_sse_enabled           = (known after apply)
      + url                               = (known after apply)
      + visibility_timeout_seconds        = 30
    }

  # aws_sqs_queue.statstracking_notification_queue_backup will be destroyed
  # (because aws_sqs_queue.statstracking_notification_queue_backup is not in configuration)
  - resource "aws_sqs_queue" "statstracking_notification_queue_backup" {
      - arn                               = "arn:aws:sqs:eu-west-1:REDACTED:statstracking-v3-test-notification-backup" -> null
      - content_based_deduplication       = false -> null
      - delay_seconds                     = 0 -> null
      - fifo_queue                        = false -> null
      - id                                = "https://sqs.eu-west-1.amazonaws.com/REDACTED/statstracking-v3-test-notification-backup" -> null
      - kms_data_key_reuse_period_seconds = 300 -> null
      - max_message_size                  = 262144 -> null
      - message_retention_seconds         = 1209600 -> null
      - name                              = "statstracking-v3-test-notification-backup" -> null
      - receive_wait_time_seconds         = 0 -> null
      - sqs_managed_sse_enabled           = false -> null
      - url                               = "https://sqs.eu-west-1.amazonaws.com/REDACTED/statstracking-v3-test-notification-backup" -> null
      - visibility_timeout_seconds        = 30 -> null
    }

Here I have tried to refactor a resource to use a for_each. The correct move command is this

moved {
  from = aws_sqs_queue.statstracking_notification_queue_backup
  to   = aws_sqs_queue.backup_queues["statstracking-v3-test-notification-backup"]
}

It seems like tfautomv should be able to pick this up because the queue has the same name in each.

edit: Running the analysis shows the mismatch failed due to changes to the tags. I see in the README I can ignore changes to certain attributes, but it would be nice to have a way of running that identified a move based only on the "primary" attribute of a resource. In this case, two queues with the same name is desirable whereas changes to tags is part of the refactor.

│ │ Mismatch: aws_sqs_queue.statstracking_notification_queue_backup
│ │ ╷
│ │ │ + tags_all.Terraformed = "True"
│ │ │ - tags_all.Terraformed = <nil>
│ │ │ + tags_all.Environment = "Dev"
│ │ │ - tags_all.Environment = "test"
│ │ │ + tags_all.Source = "REDACTED"
│ │ │ - tags_all.Source = <nil>

I see the above even when running tfautomv -terraform-bin=terragrunt -ignore="everything:aws_sqs_queue:tags_all" -ignore="everything:aws_sqs_queue:tags"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions