Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support local endpoints for SQS and S3. #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

0xkalvin
Copy link

@0xkalvin 0xkalvin commented Oct 8, 2021

Description

One common way of setting up a local development environment for AWS services is using Localstack.
In order for that to work, we need a way to point our services endpoints to a local URL that uses HTTP instead of HTTPS.

This PR adds support for passing a local endpoint for SQS and S3.

To manually test this with Localstack:

Start the Localstack container with

docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack

Create a dummy queue and a dummy s3 bucket

aws --endpoint-url=http://localhost:4566  --region=us-east-1 sqs create-queue --queue-name dummyqueue

aws --endpoint-url=http://localhost:4566 s3 mb s3://dummybucket

Run this script

aws.initialize({
  accessKeyId: 'fake_key',
  secretAccessKey: 'fake_secret',
  region: 'us-east-1'
});

const queueName = 'dummyqueue';

const sqs = aws.SQS({
  account: '000000000000',
  bypassProxy: false,
  sqsEndpoint: 'localhost:4566',
  sqsProtocol: 'http',
  s3Endpoint: 'localhost:4566',
  s3Protocol: 'http',
  s3ForcePathStyle: true
});

async function run() {
  const sendMessageResult = await sqs.extendedSend({
    queueName,
    payload: {
      foo: 'bar'
    },
    s3Bucket: 'dummybucket'
  });

  console.log(sendMessageResult);
}

run();

Kalvin Vasconcellos added 2 commits October 8, 2021 16:44
…er to work with Localstack.

A common way to set up a development environement for AWS is using Localstack.
To make that work, we need a way to pass to SQS and S3 objects which endpoint we want to use.
In case of Localstack, we need to pass a localhost url with http protocol.
@0xkalvin 0xkalvin self-assigned this Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant