Nodejs remote debugging with PROVIDER_OVERRIDE_LAMBDA=asf

When running localstack and attempting to connect a remote js debugger, I am following the guide here: https://docs.localstack.cloud/user-guide/tools/lambda-tools/debugging/#debugging-nodejs-lambdas

Iโ€™ve created a custom profile (https://docs.localstack.cloud/references/configuration/#profiles) to simplify localstack start -d

my profile is:

LAMBDA_REMOTE_DOCKER=0
EDGE_BIND_HOST=0.0.0.0
LAMBDA_DOCKER_FLAGS=-e NODE_OPTIONS=--inspect-brk=0.0.0.0:9229 -p 9229:9229
DEBUG=1
PROVIDER_OVERRIDE_LAMBDA=asf

result of localstack config show:

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Key                                โ”ƒ Value                                                   โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ BUCKET_MARKER_LOCAL                โ”‚ __local__                                               โ”‚
โ”‚ CUSTOM_SSL_CERT_PATH               โ”‚                                                         โ”‚
โ”‚ DATA_DIR                           โ”‚                                                         โ”‚
โ”‚ DEBUG                              โ”‚ True                                                    โ”‚
โ”‚ DEFAULT_REGION                     โ”‚ us-east-1                                               โ”‚
โ”‚ DEVELOP                            โ”‚ False                                                   โ”‚
โ”‚ DEVELOP_PORT                       โ”‚ 5678                                                    โ”‚
โ”‚ DISABLE_CORS_CHECKS                โ”‚ False                                                   โ”‚
โ”‚ DISABLE_CORS_HEADERS               โ”‚ False                                                   โ”‚
โ”‚ DISABLE_CUSTOM_CORS_APIGATEWAY     โ”‚ False                                                   โ”‚
โ”‚ DISABLE_CUSTOM_CORS_S3             โ”‚ False                                                   โ”‚
โ”‚ DISABLE_EVENTS                     โ”‚ False                                                   โ”‚
โ”‚ DOCKER_BRIDGE_IP                   โ”‚ 172.17.0.1                                              โ”‚
โ”‚ DYNAMODB_ERROR_PROBABILITY         โ”‚ 0.0                                                     โ”‚
โ”‚ DYNAMODB_HEAP_SIZE                 โ”‚ 256m                                                    โ”‚
โ”‚ DYNAMODB_READ_ERROR_PROBABILITY    โ”‚ 0.0                                                     โ”‚
โ”‚ DYNAMODB_SHARE_DB                  โ”‚ 0                                                       โ”‚
โ”‚ DYNAMODB_WRITE_ERROR_PROBABILITY   โ”‚ 0.0                                                     โ”‚
โ”‚ EAGER_SERVICE_LOADING              โ”‚ False                                                   โ”‚
โ”‚ EDGE_BIND_HOST                     โ”‚ 0.0.0.0                                                 โ”‚
โ”‚ EDGE_FORWARD_URL                   โ”‚                                                         โ”‚
โ”‚ EDGE_PORT                          โ”‚ 4566                                                    โ”‚
โ”‚ EDGE_PORT_HTTP                     โ”‚ 0                                                       โ”‚
โ”‚ ENABLE_CONFIG_UPDATES              โ”‚ False                                                   โ”‚
โ”‚ EXTRA_CORS_ALLOWED_HEADERS         โ”‚                                                         โ”‚
โ”‚ EXTRA_CORS_ALLOWED_ORIGINS         โ”‚                                                         โ”‚
โ”‚ EXTRA_CORS_EXPOSE_HEADERS          โ”‚                                                         โ”‚
โ”‚ HOSTNAME_EXTERNAL                  โ”‚ localstack                                              โ”‚
โ”‚ HOSTNAME_FROM_LAMBDA               โ”‚                                                         โ”‚
โ”‚ KINESIS_ERROR_PROBABILITY          โ”‚ 0.0                                                     โ”‚
โ”‚ KINESIS_INITIALIZE_STREAMS         โ”‚                                                         โ”‚
โ”‚ KINESIS_MOCK_PERSIST_INTERVAL      โ”‚ 5s                                                      โ”‚
โ”‚ LAMBDA_CODE_EXTRACT_TIME           โ”‚ 25                                                      โ”‚
โ”‚ LAMBDA_CONTAINER_REGISTRY          โ”‚ lambci/lambda                                           โ”‚
โ”‚ LAMBDA_DOCKER_DNS                  โ”‚                                                         โ”‚
โ”‚ LAMBDA_DOCKER_FLAGS                โ”‚ -e NODE_OPTIONS=--inspect-brk=0.0.0.0:9229 -p 9229:9229 โ”‚
โ”‚ LAMBDA_DOCKER_NETWORK              โ”‚                                                         โ”‚
โ”‚ LAMBDA_EXECUTOR                    โ”‚                                                         โ”‚
โ”‚ LAMBDA_FALLBACK_URL                โ”‚                                                         โ”‚
โ”‚ LAMBDA_FORWARD_URL                 โ”‚                                                         โ”‚
โ”‚ LAMBDA_JAVA_OPTS                   โ”‚                                                         โ”‚
โ”‚ LAMBDA_REMOTE_DOCKER               โ”‚ False                                                   โ”‚
โ”‚ LAMBDA_REMOVE_CONTAINERS           โ”‚ True                                                    โ”‚
โ”‚ LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT โ”‚ 10                                                      โ”‚
โ”‚ LAMBDA_RUNTIME_EXECUTOR            โ”‚                                                         โ”‚
โ”‚ LAMBDA_STAY_OPEN_MODE              โ”‚ False                                                   โ”‚
โ”‚ LAMBDA_TRUNCATE_STDOUT             โ”‚ 2000                                                    โ”‚
โ”‚ LEGACY_DIRECTORIES                 โ”‚ False                                                   โ”‚
โ”‚ LEGACY_DOCKER_CLIENT               โ”‚ False                                                   โ”‚
โ”‚ LEGACY_EDGE_PROXY                  โ”‚ False                                                   โ”‚
โ”‚ LOCALSTACK_HOSTNAME                โ”‚ localhost                                               โ”‚
โ”‚ LS_LOG                             โ”‚ False                                                   โ”‚
โ”‚ MAIN_CONTAINER_NAME                โ”‚ localstack_main                                         โ”‚
โ”‚ OPENSEARCH_ENDPOINT_STRATEGY       โ”‚ domain                                                  โ”‚
โ”‚ OUTBOUND_HTTPS_PROXY               โ”‚                                                         โ”‚
โ”‚ OUTBOUND_HTTP_PROXY                โ”‚                                                         โ”‚
โ”‚ PERSISTENCE                        โ”‚ False                                                   โ”‚
โ”‚ S3_SKIP_SIGNATURE_VALIDATION       โ”‚ True                                                    โ”‚
โ”‚ SKIP_INFRA_DOWNLOADS               โ”‚                                                         โ”‚
โ”‚ SKIP_SSL_CERT_DOWNLOAD             โ”‚ False                                                   โ”‚
โ”‚ SQS_DELAY_PURGE_RETRY              โ”‚ False                                                   โ”‚
โ”‚ SQS_DELAY_RECENTLY_DELETED         โ”‚ False                                                   โ”‚
โ”‚ SQS_ENDPOINT_STRATEGY              โ”‚ off                                                     โ”‚
โ”‚ SQS_PORT_EXTERNAL                  โ”‚ 0                                                       โ”‚
โ”‚ STEPFUNCTIONS_LAMBDA_ENDPOINT      โ”‚                                                         โ”‚
โ”‚ SYNCHRONOUS_KINESIS_EVENTS         โ”‚ True                                                    โ”‚
โ”‚ SYNCHRONOUS_SNS_EVENTS             โ”‚ False                                                   โ”‚
โ”‚ TF_COMPAT_MODE                     โ”‚ False                                                   โ”‚
โ”‚ USE_SINGLE_REGION                  โ”‚ False                                                   โ”‚
โ”‚ USE_SSL                            โ”‚ False                                                   โ”‚
โ”‚ WAIT_FOR_DEBUGGER                  โ”‚ False                                                   โ”‚
โ”‚ WINDOWS_DOCKER_MOUNT_PREFIX        โ”‚ /host_mnt                                               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

However, when I start a lambda task, the container does not expose any ports. see docker ps output:

CONTAINER ID   IMAGE                             COMMAND                  CREATED          STATUS                    PORTS                                                                                                                  NAMES
8577b6ae7369   public.ecr.aws/lambda/nodejs:18   "/var/rapid/init"        38 minutes ago   Up 38 minutes                                                                                                                                    9ffd8d7ea1c59a638cc0276861d0e1e4
9b26cbe3cc23   localstack/localstack             "docker-entrypoint.sh"   43 minutes ago   Up 43 minutes (healthy)   0.0.0.0:4510-4559->4510-4559/tcp, 0.0.0.0:4566->4566/tcp, 0.0.0.0:4571->4571/tcp, 0.0.0.0:12121->12121/tcp, 5678/tcp   localstack_main

per the localstack_main container logs, no ports appear to be passed to the lambda and the NODE_OPTIONS is not sent when created:

2022-12-15T22:22:27.661 DEBUG --- [cation_loop)] l.u.c.docker_sdk_client    : Creating container with attributes: {'mount_volumes': None, 'ports': None, 'cap_add': None, 'cap_drop': None, 'security_opt': None, 'dns': None, 'additional_flags': None, 'workdir': None, 'privileged': None, 'command': None, 'detach': None, 'entrypoint': '/var/rapid/init', 'env_vars': {'LOCALSTACK_RUNTIME_ID': '9ffd8d7ea1c59a638cc0276861d0e1e4', 'LOCALSTACK_RUNTIME_ENDPOINT': 'http://172.17.0.2:4566/_localstack_lambda/9ffd8d7ea1c59a638cc0276861d0e1e4', 'AWS_LAMBDA_LOG_GROUP_NAME': '/aws/lambda/XXXXXX', 'AWS_LAMBDA_LOG_STREAM_NAME': '2022/12/15/[$LATEST]9ffd8d7ea1c59a638cc0276861d0e1e4', 'AWS_LAMBDA_FUNCTION_NAME': 'XXXXXX', 'AWS_LAMBDA_FUNCTION_TIMEOUT': 30, 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE': 512, 'AWS_LAMBDA_FUNCTION_VERSION': '$LATEST', 'AWS_DEFAULT_REGION': 'us-east-1', 'TASK_ROOT': '/var/task', 'RUNTIME_ROOT': '/var/runtime', 'AWS_LAMBDA_INITIALIZATION_TYPE': 'on-demand', 'TZ': ':UTC',  'LOCALSTACK_HOSTNAME': '172.17.0.2', 'EDGE_PORT': '4566', 'AWS_ENDPOINT_URL': 'http://172.17.0.2:4566', '_HANDLER': './src/index.handler', 'AWS_EXECUTION_ENV': 'Aws_Lambda_nodejs18.x'}, 'image_name': 'public.ecr.aws/lambda/nodejs:18', 'interactive': None, 'name': '9ffd8d7ea1c59a638cc0276861d0e1e4', 'network': 'bridge', 'remove': None, 'self': <localstack.utils.container_utils.docker_sdk_client.SdkDockerClient object at 0x7f0b653b79a0>, 'tty': None, 'user': None}

Am I missing something or is this a bug? We want to use nodejs18.x and from everything Iโ€™ve read we have to use the ASF lambda provider.

Hello!
You are right, the functionality of LAMBDA_DOCKER_FLAGS is currently missing in this provider.
We will add it as soon as possible.

Hi again!
This feature has been added to the asf provider now, and should be available in the :latest docker image!
Thank you for the question!

1 Like