Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do get a simple localstack/localstack to work with node.js

I'm trying to get a local docker instance of localstack/localstack to work with node.js aws-sdk library. But I can get a simple createTopic to work on an sns client.

I have started the docker image with this command and

docker run -d -p 4567-4583:4567-4583 localstack/localstack

The code that I am running....

const AWS = require('aws-sdk')

AWS.config.update({
  accessKeyId: 'something',
  secretAccessKey: 'something',
  region:'us-east-1',
  logger: process.stdout
})

const sns = new AWS.SNS({endpoint:'http://localhost::4575'})
sns.createTopic({Name:'testing123'})
  .promise()
  .then(console.log)
  .catch(console.error)

And the error that is returned....

[AWS sns 404 0.035s 0 retries] createTopic({ Name: 'testing123' }) { 404: null at Request.extractError (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/protocol/query.js:52:29) at Request.callListeners (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/request.js:683:14) at Request.transition (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/state_machine.js:14:12) at /Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/request.js:38:9) at Request. (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/request.js:685:12) at Request.callListeners (/Users/t.smith/workspace/scratch/fake-sns-testing/node_modules/aws-sdk/lib/sequential_executor.js:115:18) message: null, code: 404, time: 2018-04-23T09:56:50.296Z,
requestId: undefined, statusCode: 404, retryable: false,
retryDelay: 95.466505112399 }

I would like to hear from anyone who has successfully managed to work with a localstack/localstack docker image with node.js. Thanks.

like image 833
thomas-peter Avatar asked Apr 23 '18 09:04

thomas-peter


People also ask

Can we run LocalStack without Docker?

LocalStack is a standalone application and can be run outside of Docker but it doesn't support every operating system. I will not go into details running LocalStack outside of docker, just check their documentation.

How do I access LocalStack UI?

You can view your data in LocalStack directly from Commandeer getcommandeer.com/blog/install-localstack .

How do I open LocalStack?

The easiest way to start and manage LocalStack - either on your machine, in a Docker container on your machine, or even on a remote Docker host. Get a desktop experience and work with your local LocalStack instance via the UI. Use the docker CLI to manually start the LocalStack Docker container.


1 Answers

The answer is to correct the SNS endpoint by removing double : in the url.

like image 118
Hugodby Avatar answered Nov 03 '22 10:11

Hugodby