0

Ive a lambda and a dynaoDB set in a localstack. The dyanmodDB table is correctly created(visible in web localstack + awslocal dynamodb list-tables in localstack-main container bash)

In localstack-main ( in eu-west-3)

{
    "TableNames": [
        "leads",
        "dealers"
    ]
}

In my lambda i try to :

import os,boto3
url = os.getenv("LOCALSTACK_HOSTNAME") #=some ip
port = os.getenv("EDGE_PORT") #verified = 4566
localstack_endpoint =f"http://{url}:{port}"

dynamodb = boto3.resource("dynamodb", region_name="eu-west-3",endpoint_url=localstack_endpoint)
table = dynamodb.Table("dealers")

I get a Cannot do operations on a non-existent table. I gt the same thing by replacing url by localhost.localstack.cloud.Replacing with localhost i just get no connection

dynamodb = boto3.resource("dynamodb", region_name="eu-west-3", endpoint_url=localstack_endpoint)
tables = list(dynamodb.tables.all())  
print(tables)

\>>>[ ]

Here's my docker-compose

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack:4.0.3
    ports:
      - "4566:4566"              # LocalStack Gateway
      - "4510-4559:4510-4559"    # external services port range
    environment:
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=${DEBUG:-0}
      - AWS_DEFAULT_REGION=eu-west-3
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

I want to get access to the dynamoDB from the lambda in localstack

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.