I understand the error but am very unsure why it is happening.

    with AmazonDaxClient.resource(
            endpoint_url='daxs://test.<chars>.dax-clusters.<region>.amazonaws.com',
            region_name='<region>'
    ) as dynamodb:
        table = dynamodb.Table('<table_name>')

        stmt = """
    for i in range(3):
        table.get_item(Key={
            'id': str(i),
            'date': str(dt + relativedelta(days=i))
        })
        """

        timer = timeit.Timer(stmt, globals={'relativedelta': relativedelta, 'dt': date.today(), 'table': table})
        result = timer.repeat(repeat, n)

        return result

I'm just trying to benchmark some read/write times to different databases that are available to me but can't get DAX to work while the standard connection to DynamoDB through boto3 seems to work fine. Any input would be very helpful

Edit: This is on a Lambda and here is the full error message:

{
  "errorMessage": "invalid literal for int() with base 10: '//test.<chars>.dax-clusters.<region>.amazonaws.com'",
  "errorType": "ValueError",
  "stackTrace": [
    "  File \"/var/task/handler.py\", line 102, in handler\n    results = test_func(repeat, n)\n",
    "  File \"/var/task/handler.py\", line 316, in test\n    with AmazonDaxClient.resource(\n",
    "  File \"/var/task/amazondax/AmazonDaxClient.py\", line 86, in resource\n    res = session.resource('dynamodb', region_name=region_name, api_version=api_version,\n",
    "  File \"/var/task/amazondax/Resource.py\", line 68, in resource\n    res = super(DaxSession, self).resource('dynamodb',\n",
    "  File \"/var/task/boto3/session.py\", line 396, in resource\n    client = self.client(\n",
    "  File \"/var/task/amazondax/Resource.py\", line 52, in client\n    return AmazonDaxClient(self,\n",
    "  File \"/var/task/amazondax/AmazonDaxClient.py\", line 177, in __init__\n    self._cluster = Cluster(self._region_name,\n",
    "  File \"/var/task/amazondax/Cluster.py\", line 30, in __init__\n    self._discovery_endpoints = [_parse_host_ports(endpoint) for endpoint in discovery_endpoints]\n",
    "  File \"/var/task/amazondax/Cluster.py\", line 30, in <listcomp>\n    self._discovery_endpoints = [_parse_host_ports(endpoint) for endpoint in discovery_endpoints]\n",
    "  File \"/var/task/amazondax/Cluster.py\", line 116, in _parse_host_ports\n    return parts[0].strip(), int(parts[1].strip())\n"
  ]
}
1

There are 1 answers

2
Kyle On BEST ANSWER

Ended up changing the endpoint_url to test.<chars>.dax-clusters.<region>.amazonaws.com. This ended up resulting in an error telling me that the cluster endpoints were failing. I ended up having to make sure that the Lambda's security group was specified in the inbound/outbound rules for the security group that the DAX cluster was using.