Skip to content

Commit 910a613

Browse files
committed
fix the localstack container host ip
1 parent 6148030 commit 910a613

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

vault/localstack_vault/extension.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import requests
77

88
from localstack import config, constants
9+
from localstack.utils.container_networking import get_main_container_ip
910
from localstack.utils.net import get_addressable_container_host
1011
from localstack_extensions.utils.docker import ProxiedDockerContainerExtension
1112

@@ -140,7 +141,12 @@ def _configure_iam_auth(self, client: hvac.Client):
140141
LOG.info("Enabled AWS auth method at aws/")
141142

142143
# Configure the AWS auth to use LocalStack's STS endpoint
143-
localstack_endpoint = f"http://{get_addressable_container_host()}:{config.get_edge_port_http()}"
144+
# Use get_main_container_ip() to get LocalStack's actual container IP
145+
# on the Docker network (e.g., 172.17.0.2), which is reachable from
146+
# the Vault container. get_addressable_container_host() returns the
147+
# Docker gateway IP (172.17.0.1), which may not be accessible.
148+
localstack_ip = get_main_container_ip()
149+
localstack_endpoint = f"http://{localstack_ip}:{config.get_edge_port_http()}"
144150

145151
client.auth.aws.configure(
146152
sts_endpoint=localstack_endpoint,

0 commit comments

Comments
 (0)