I have a pretty normal localstack setup, with this part in the docker-compose.yml file
localstack:
container_name: "localstack"
image: localstack/localstack
hostname: localstack
networks:
- ms-estates
ports:
- "127.0.0.1:53:53"
- "127.0.0.1:53:53/udp"
- "127.0.0.1:443:443"
- "127.0.0.1:4566:4566"
- "127.0.0.1:4571:4571"
environment:
- AWS_DEFAULT_REGION=eu-central-1
- SERVICES=apigateway,lambda,sqs,secretsmanager,s3,cloudformation,sts,iam,route53
- DEBUG=1
# - LAMBDA_EXECUTOR=docker-reuse
- LAMBDA_REMOTE_DOCKER=false
- LAMBDA_REMOVE_CONTAINERS=true
- LAMBDA_DOCKER_NETWORK=ms-estates
- AWS_XRAY_SDK_ENABLED=true
- DOCKER_HOST=unix:///var/run/docker.sock
- DATA_DIR=/tmp/localstack/data
- START_WEB=1
- HOSTNAME_EXTERNAL=localstack
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
- ./localstack:/docker-entrypoint-initaws.d
and this is the serverless-localstack part I have in the serverless.yml file:
custom:
localstack:
stages:
- local
lambda:
mountCode: True
# endpointFile: localstack_endpoints.json
endpoints:
SecretsManager: http://localstack:4566
secretsmanager: http://localstack:4566
You see I even tried different cases and endpointsFile property with the same result.
The problem I'm having is that when I try to connect to the Secrets Manager (or any other service) my code is still trying to knock to the AWS service
constructor() {
this.secretsManager = new SecretsManager();
}
This part is going to try to reach this URL secretsmanager.eu-central-1.amazonaws.com
How can I make my code talk to the local service instances without “if env” hacks?