I installed localstack and awscli within a docker container. I run different aws commands to list streams and buckets but when I tried to list dynamoDB tables (as below), it failed :
aws --region us-east-1 --endpoint-url=http://localhost:4569 dynamodb list-tables
Here is the error I get :
2018-07-12T09:26:35:ERROR:localstack.services.generic_proxy: Error forwarding request: HTTPConnectionPool(host='127.0.0.1', port=4564): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f68941a43d0>: Failed to establish a new connection: [Errno 111] Connection refused',)) Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/localstack/services/generic_proxy.py", line 201, in forward
headers=forward_headers)
File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 508,in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 618,in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 508,in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=4564): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f68941a43d0>: Failed to establish a new connection: [Errno 111] Connection refused',))
I did not find on internet any response that solved my problem.
If anyone has a clue or an idea, I will be thankful.
Thanks in advance
If you want to view your Dynamo DB on localstack, you can install Commandeer, which gives you a UI for both local and AWS. https://getcommandeer.com
If you are using Java, you can use the jar
library for simulate some amazon components:
In first instance you need to add the following component in your pom.xml
in order to be able to initialize the localstack directly during the test:
<dependency>
<groupId>cloud.localstack</groupId>
<artifactId>localstack-utils</artifactId>
<version>0.2.0</version>
<scope>test</scope>
</dependency>
Then, you need to specify the following library if you need to use dynamo cause the latest one proivded from aws
are not compliant with the latest version of localstack:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.721</version>
<scope>test</scope>
</dependency>
Now you can use the following annotations in order to instantiate the stack using docker, the images will be pulled automatically if not present in the system. So no is not necessary to run any docker/docker-compose image.
@LocalstackDockerProperties(services = {"dynamodb"})
@ExtendWith(LocalstackDockerExtension.class)
@Slf4j
public class TestPipelineComplete {
public static final String AWS_ACCESS_KEY_ID = "foo";
public static final String AWS_SECRET_ACCESS_KEY = "bar";
static {
System.setProperty("AWS_ACCESS_KEY_ID", AWS_ACCESS_KEY_ID);
System.setProperty("AWS_SECRET_ACCESS_KEY", AWS_SECRET_ACCESS_KEY);
}
}
Now, if you need to initialize a DynamoDB
client you can use the following line:
final AmazonDynamoDB clientDynamoDB = cloud.localstack.TestUtils.getClientDynamoDB();
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