Connection to localstack
Closed this issue · 8 comments
Will this package work with localstack. How do I connect to localstack. Any help appreciated?
Hi @rabalasubramani3 I am not familiar with local stack. Do you have an example for how another sdk works with it (if possible boto3)? I can then use that as a template to address the issue 😁
It looks like you only need to change the endpoint (correct me if I am wrong). So it should work similar to how we can connect to minio s3.
I will see if I can get it spun up on my local computer and update the ticket accordingly :)
I tried various versions of these.. i.e tryied different endpoint
s3 <- paws::s3(
config = list(
credentials = list(
creds = list(
access_key_id = "foo",
secret_access_key = "bar"
)
),
endpoint='http://s3.localhost.localstack.cloud:4566',
region='us-east-1'
Here is my localstack docker-compose.yml
localstack:
image: localstack/localstack:2.0.0
container_name: sagpro_localstack
environment:
- AWS_DEFAULT_REGION=us-east-1
- DOCKER_HOST=unix:///var/run/docker.sock
- AWS_ACCESS_KEY_ID=foo
- AWS_SECRET_ACCESS_KEY=bar
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
volumes:
- sagpro_localstack_volume:/var/lib/localstack
- /var/run/docker.sock:/var/run/docker.sock
networks:
- sagpro-net
Hi @rabalasubramani3 I am not familiar with local stack. Do you have an example for how another sdk works with it (if possible boto3)? I can then use that as a template to address the issue 😁
localstack allows you to mimic AWS setup locally.
boto3
AWS_LOCALSTACK_ENDPOINT_URL = 'http://localhost:4566'
AWS_ACCESS_KEY_ID ='foo'
AWS_SECRET_ACCESS_KEY = 'bar'
AWS_DEFAULT_REGION = 'us-east-1'
def get_local_storage_client():
client = boto3.client('s3',
endpoint_url=AWS_LOCALSTACK_ENDPOINT_URL,
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
region_name=AWS_DEFAULT_REGION,
config=Config(s3={'addressing_style': 'path'})
)
Got it working now.
s3 <- paws::s3(
config = list(
credentials = list(
creds = list(
access_key_id = "foo",
secret_access_key = "bar"
)
),
endpoint='http://localstack:4566',
region='us-east-1'
)
)
within "localstack" R-studio and localstack all sitting in same network.
For completeness you can set all your login details in the aws configs. So for example:
.aws/credentials
[localstack]
aws_access_key_id=youraccesskey
aws_secret_access_key=yoursecretkey
.aws/config
[profile localstack]
region=us-east-1
output=json
services = localstack
[services localstack]
s3 =
endpoint_url = http://localstack:4566/
library(paws)
client <- s3(config(credentials(profile ="localstack")))
Closing this ticket