Search code examples
amazon-web-servicesterraformamazon-sqsamazon-snslocalstack

Unable to find subscription for given ARN


I am testing my AWS terraform configuration with LocalStack. The final goal is to make a queue listen to my topic.

I am running Localstack with the following command:

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

After running the command terraform destroy I get the error message:

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
│
│
╵

I have run the code against the real AWS without a problem.

Here is the code for the terraform file

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
}

Solution

  • This has been fixed with issue:

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