无法找到给定 ARN

问题描述

我正在使用 LocalStack 测试我的 AWS terraform 配置。最终目标是让队列听我的话题。

我正在使用以下命令运行 Localstack:

docker run --rm -it -p 4566:4566 localstack/localstack

运行命令 terraform destroy 后,我收到错误消息:

aws_sns_topic_subscription.subscription: Destroying... [id=arn:aws:sns:us-east-1:000000000000:topic:a0d47652-3ae4-46df-9b63-3cb6e154cfcd]
╷
│ Error: error waiting for SNS topic subscription (arn:aws:sns:us-east-1:000000000000:topic:a0d47652-3ae4-46df-9b63-3cb6e154cfcd) deletion: InvalidParameter: Unable to find subscription for given ARN
│   status code: 400,request id: 2168e636
│
│
╵

我已经在真正的 AWS 上运行了代码,没有任何问题。

这是terraform文件代码

terraform {
  required_version = ">= 0.12.26"
}

provider "aws" {
  region                      = "us-east-1"
  s3_force_path_style         = true
  skip_credentials_validation = true
  skip_Metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    sns            = "http://localhost:4566"
    sqs            = "http://localhost:4566"
  }
}

resource "aws_sqs_queue" "queue" {
  name = "queue"
}

resource "aws_sns_topic" "topic" {
  name = "topic"
}

resource "aws_sns_topic_subscription" "subscription" {
  endpoint = aws_sqs_queue.queue.arn
  protocol = "sqs"
  topic_arn = aws_sns_topic.topic.arn
}

解决方法

遗憾的是,这是 AWS 的一个问题,您必须创建票证外观 herehttps://stackoverflow.com/a/64568018/6085193

"When you delete a topic,subscriptions to the topic will not be "deleted" immediately,but become orphans. SNS will periodically clean these orphans,usually every 10 hours,but not guaranteed. If you create a new topic with the same topic name before these orphans are cleared up,the new topic will not inherit these orphans. So,no worry about them"

,

此问题已修复:

https://github.com/localstack/localstack/issues/4022