Skip to content

bug: SNS cross region topic subscription fails (CloudFormation) #12670

Closed
@codenem

Description

@codenem

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Starting version 4.1.0, subscribing to a topic from a different region fails with the following:

An error occurred (NotFound) when calling the Subscribe operation: Topic does not exist

I think the bug has been introduced by #12175, with the intention of raising the error for legit cases.

The code might be pretty self explanatory of the bug. If I understand correctly, here we should check the store corresponding to the region of the topic ARN we want to subscribe to, not the store of the region we are subscribing from.

Expected Behavior

Subscribing to a topic from a different region succeeds.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack-pro:4.1.0 # required for Pro
    ports:
      - "127.0.0.1:4566:4566" # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559" # external services port range
      - "127.0.0.1:443:443" # LocalStack HTTPS Gateway (Pro)
    environment:
      # Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
      - LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?} # required for Pro
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=${DEBUG:-0}
      - PERSISTENCE=${PERSISTENCE:-1}
      - ENFORCE_IAM=0
      - SNAPSHOT_LOAD_STRATEGY=ON_STARTUP
      - SNAPSHOT_SAVE_STRATEGY=ON_SHUTDOWN
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

user@XYZ:~$ awslocal sqs create-queue --queue-name my-queue --region eu-west-1
{
    "QueueUrl": "http://sqs.eu-west-1.localhost.localstack.cloud:4566/000000000000/my-queue"
}
user@XYZ:~$ awslocal sns create-topic --name my-topic --region us-east-1
{
    "TopicArn": "arn:aws:sns:us-east-1:000000000000:my-topic"
}
user@XYZ:~$ awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:000000000000:my-topic" --protocol sqs --notification-endpoint "arn:aws:sqs:eu-west-1:000000000000:my-queue" --region eu-west-1

An error occurred (NotFound) when calling the Subscribe operation: Topic does not exist

Environment

- OS: macOS Sequoia 15.5 (24F74) 
- LocalStack:
  LocalStack version: 4.1.0
  LocalStack Docker image sha: sha256:a60a3e7a1e9dd988bd42c7bf0b0355e0595a68b15cd24d6df3562583cb6da10a
  LocalStack build date: 2025-01-30
  LocalStack build git hash: 8a211b8ef2c35099bc6813ff24a962d32ddc402e

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions