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.
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.
You can view your data in LocalStack directly from Commandeer getcommandeer.com/blog/install-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.
The answer is to correct the SNS endpoint by removing double :
in the url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With