title: How to avoid connection to AWS region when @SQSListener is configured
body: <p>I have an issue while testing my application in localstack. The requirement is simple. I would like to subscribe to a topic in AWS-SNS with SQS subscription. In localstack when I am executing when I configure @SQSListener it tries to validate the credentials with AWS and I get the below error message:</p>
  
  <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMessageListenerContainer' defined in class path resource [org/springframework/cloud/aws/messaging/config/annotation/SqsConfiguration.class]: Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: </p>
  
  <p>I tried setting up a dummy credentials for localstack that did not help either. I tried searching on net but could not find any relevant posts on this.</p>
  
  <h2>Code</h2>
  
  <pre><code>@Slf4j
  @Configuration
  @Profile("local")
  @EnableSns
  @EnableSqs
  public class LocalStackConfiguration {
  
  
      @Value("${sqsClassifierQueueName}")
      private String sqsClassifierQueueName;
  
      @Value("${sqsConsQueueNames}")
      private List&lt;String&gt; sqsConsQueueNames;
  
      @Bean(name = "amazonSqs")
      public AmazonSQS configureSQSClient()
              throws MalformedURLException
      {
          log.info("Loading local SQS client");
          BasicAWSCredentials awsCreds = new BasicAWSCredentials("user", "password");
  
          AmazonSQS sqsClient = AmazonSQSClientBuilder.standard()
                  .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                  .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:4576", "us-east-1"))
                  .build();
  
          sqsClient.createQueue(sqsClassifierQueueName);
          sqsConsQueueNames.forEach(queueName -&gt; sqsClient.createQueue(queueName));
          //log.info("Device Registry queue Created: " + sqsClient.createQueue(REGISTRY_QUEUE_URL.substring(REGISTRY_QUEUE_URL.lastIndexOf('/') + 1)));
          return sqsClient;
      }
  
      @Bean(name = "amazonSns")
      public AmazonSNS configureSNSClient() {
          AmazonSNS snsClient= AmazonSNSClientBuilder.standard()
                  .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("user", "password")))
                  .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:4575", "us-east-1"))
                  .build();
          return snsClient;
      }
  
  
  
  }
  
  
  @Component
  @DependsOn(value = {"amazonSns", "amazonSqs"})
  public class SNSSubscription {
  
      @Qualifier("amazonSns")
      @Autowired
      private AmazonSNS sns;
  
      @Qualifier("amazonSqs")
      @Autowired
      private AmazonSQS sqs;
  
      @Value("${snsClassifierTopicName}")
      private String snsClassifierTopicName;
  
      @Value("${sqsClassifierQueueName}")
      private String sqsClassifierQueueName;
  
      @PostConstruct
      public void subscribeToTopics() {
          subscribeToClassifierTopics();
      }
  
      private void subscribeToClassifierTopics() {
          SNSSubscriptionUtils.subscribeToSQS(sns, sqs, snsClassifierTopicName, sqsClassifierQueueName);
  
      }
  
      @SqsListener(value="${snsClassifierTopicName}")
      public void receiveMessage(Object obj){
          System.out.println(obj);
      }
  }
  
  
  
  public class SNSSubscriptionUtils {
  
      public static void subscribeToSQS(AmazonSNS sns, AmazonSQS sqs, String topicName, String queueName) {
          String snsTopicArn = getSnsTopicArn(sns, topicName);
          String queueUrl = SQSUtils.getQueueUrl(sqs, queueName);
          Topics.subscribeQueue(sns, sqs, snsTopicArn, queueUrl);
      }
  
      public static String getSnsTopicArn(AmazonSNS sns, String topicName) {
          String topicArn = sns.createTopic(topicName).getTopicArn();
          return topicArn;
      }
  }
  
  
  public class SQSUtils {
  
      public static String getQueueUrl(AmazonSQS sqs, String queueName) {
          GetQueueUrlRequest queueUrlRequest = new GetQueueUrlRequest(queueName);
          return sqs.getQueueUrl(queueUrlRequest).getQueueUrl();
      }
  }
  </code></pre>