feat(lambda): support extra /etc/hosts entries on Lambda launch (#2073)

* feat(lambda): support extra /etc/hosts entries via FLOCI_SERVICES_LAMBDA_EXTRA_HOSTS

* feat(lambda): support ipv6 addresses.

---------

Co-authored-by: Florian Overfelt <joverfelt@meso-scale.com>
This commit is contained in:
floverfeltandFlorian Overfelt authored and GitHub committed 2026-08-04 21:50:25 -05:00
1 parent fa96b791b4
commit b543aa4baa
5 files changed
+71

No files matched your search

@@ -1343,6 +1343,15 @@ public interface EmulatorConfig {
/** Docker network to attach Lambda containers to. Empty = default bridge. */
Optional<String> dockerNetwork();
/**
* Extra /etc/hosts entries added to every Lambda container, as "hostname:ip" pairs.
* The ip may be the literal "host-gateway" to map to the Docker host, mirroring
* {@code docker run --add-host hostname:host-gateway}.
*
* Env var: FLOCI_SERVICES_LAMBDA_EXTRA_HOSTS (comma-separated)
*/
Optional<List<String>> extraHosts();
/**
* Concurrent executions ceiling applied per region. AWS Lambda's
* "account-level" concurrency is in fact a per-region quota (default 1000);
@@ -223,6 +223,18 @@ public class ContainerLauncher {
specBuilder.withEmbeddedDns();
// Inject extra hosts entries into the container if present. Split on the FIRST
// colon, mirroring docker --add-host: hostnames cannot contain colons, but IPv6
// addresses do (e.g. "db.internal:2001:db8::1").
config.services().lambda().extraHosts().ifPresent(hosts -> hosts.forEach(entry -> {
int sep = entry.indexOf(':');
if (sep <= 0 || sep == entry.length() - 1) {
LOG.warnv("Ignoring malformed lambda extra-hosts entry (expected hostname:ip): {0}", entry);
return;
}
specBuilder.withExtraHost(entry.substring(0, sep), entry.substring(sep + 1));
}));
// Whether /var/task is served from a shared read-only volume (large code) or copied
// directly into this container (small code). Decided once here so both the spec (below)
// and the create->start copy block agree.