Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bug: SNS subscribe doesn't raise error when topic does not exist #12174

Closed
@coleman-c

Description

@coleman-c

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I attempt to subscribe to a topic which doesn't exist localstack succeeds and returns a subscription arn.

user@XYZ:~$ awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:000000000000:topic-does-which-does-not-exist" --protocol sqs --notification-endpoint "arn:aws:sqs:us-east-1:000000000000:my-queue"
{
    "SubscriptionArn": "arn:aws:sns:us-east-1:000000000000:localstack-topic-does-not-exist:8c98427f-bfea-4b0f-88ab-4a377e113312"
}

Performing the same action against an aws account:

user@XYZ:~$ aws --profile my-aws-profile sns subscribe --topic-arn "arn:aws:sns:eu-west-1:123456789012:topic-does-which-does-not-exist" --protocol sqs --notification-endpoint "arn:aws:sqs:eu-west-1:123456789012:my-queue"

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

Expected Behavior

To return the topic does not exist error in line with the aws behavior.

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:latest
    ports:
      - "4566:4566"           
    environment:
      - HOSTNAME_EXTERNAL=localstack
      - DEBUG=${LOCASTACK_DEBUG:-1}
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
      - DOCKER_HOST=unix:///var/run/docker.sock
      - LS_LOG=trace
    volumes:
      - "${LOCALSTACK_DATA_DIR:-./.data/localstack/internal}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
    networks:
      local-development:
        aliases:     
          - sqs.us-east-1.localstack
          - sns.us-east-1.localstack

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

user@XYZ:~$ awslocal  sqs create-queue --queue-name my-queue
{
    "QueueUrl": "http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/my-queue"
}
user@XYZ:~$ awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:000000000000:topic-does-which-does-not-exist" --protocol sqs --notification-endpoint "arn:aws:sqs:us-east-1:000000000000:my-queue"
oes-not-exist" --protocol sqs --notification-endpoint "arn:aws:sqs:us-east-1:000000000000:my-queue"
{
    "SubscriptionArn": "arn:aws:sns:us-east-1:000000000000:topic-does-which-does-not-exist:832d9fef-a2f0-4c86-955a-562b6521cd84"
}

Environment

- OS: Ubuntu 22.04 on WSL2
- LocalStack:
  LocalStack version: 4.0.4.dev115
  LocalStack Docker image sha: sha256:035d71eccf98f862d54301342ff41094d92fd780f0a384ab90328b08ea8a11f3
  LocalStack build date: 2025-01-22
  LocalStack build git hash: 6fea92c71

Anything else?

Reverting to 3.0.0 restores the expected behavior

Metadata

Metadata

Assignees

Labels

aws:snsAmazon Simple Notification Servicestatus: resolved/fixedResolved with a fix or an implementationtype: bugBug report

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions