Feat/lambda image config working directory (#673)

* feat(lambda): support ImageConfig.WorkingDirectory override

Propagate WorkingDirectory from the Lambda ImageConfig through the full
stack so container images that rely on a specific WORKDIR can be invoked
correctly, matching real AWS behavior.

- LambdaFunction: add imageConfigWorkingDirectory field + getter/setter
- LambdaService: parse WorkingDirectory on CreateFunction and
  UpdateFunctionConfiguration
- ContainerSpec: add workingDir record component
- ContainerBuilder: add withWorkingDir() fluent method
- ContainerLifecycleManager: pass workingDir to Docker via withWorkingDir()
- ContainerLauncher: apply workingDir when building the container spec
- LambdaController: serialize WorkingDirectory in ImageConfigResponse

* test(lambda): add tests for ImageConfig.WorkingDirectory

Unit tests (LambdaImageConfigTest):
- CreateFunction stores WorkingDirectory alongside Command/EntryPoint
- createFunction with all three fields together
- updateFunctionConfiguration updates and clears WorkingDirectory
- ContainerLauncher passes workingDir to ContainerSpec

Compat tests across all SDKs:
- awscli (lambda.bats): create/get/update WorkingDirectory round-trip
- Java SDK (LambdaFunctionConfigTest): ImageConfig.WorkingDirectory round-trip
- Python (test_lambda_function_config.py): TestImageConfigWorkingDirectory class
- Node (lambda.test.ts): create/update WorkingDirectory assertions
- Go (lambda_test.go): TestLambdaImageConfigWorkingDirectory subtests
- Rust (lambda_test.rs): full create/get/update round-trip
This commit is contained in:
Yorí authored and GitHub committed 2026-04-30 17:25:03 -05:00
1 parent 2dd748ee07
commit 8eeb2244a7
14 files changed
+494 -5

No files matched your search

@@ -218,4 +218,51 @@ class LambdaFunctionConfigTest {
.as("Environment block must be present even after clearing variables")
.isNotNull();
}
@Test
@Order(6)
@DisplayName("ImageConfig.WorkingDirectory round-trips via create and get")
void imageConfigWorkingDirectoryRoundTrips() {
String imageFn = TestFixtures.uniqueName("fn-image-wd");
try {
CreateFunctionResponse createResp = lambda.createFunction(CreateFunctionRequest.builder()
.functionName(imageFn)
.packageType(software.amazon.awssdk.services.lambda.model.PackageType.IMAGE)
.role(ROLE)
.code(FunctionCode.builder()
.imageUri("000000000000.dkr.ecr.us-east-1.amazonaws.com/fake-repo:latest")
.build())
.imageConfig(software.amazon.awssdk.services.lambda.model.ImageConfig.builder()
.workingDirectory("/app")
.build())
.build());
assertThat(createResp.imageConfigResponse().imageConfig().workingDirectory())
.as("CreateFunction response must include ImageConfig.WorkingDirectory")
.isEqualTo("/app");
GetFunctionConfigurationResponse getResp = lambda.getFunctionConfiguration(
GetFunctionConfigurationRequest.builder().functionName(imageFn).build());
assertThat(getResp.imageConfigResponse().imageConfig().workingDirectory())
.as("GetFunctionConfiguration must persist ImageConfig.WorkingDirectory")
.isEqualTo("/app");
UpdateFunctionConfigurationResponse updateResp = lambda.updateFunctionConfiguration(
UpdateFunctionConfigurationRequest.builder()
.functionName(imageFn)
.imageConfig(software.amazon.awssdk.services.lambda.model.ImageConfig.builder()
.workingDirectory("/updated")
.build())
.build());
assertThat(updateResp.imageConfigResponse().imageConfig().workingDirectory())
.as("UpdateFunctionConfiguration must update ImageConfig.WorkingDirectory")
.isEqualTo("/updated");
} finally {
try {
lambda.deleteFunction(DeleteFunctionRequest.builder().functionName(imageFn).build());
} catch (Exception ignored) {}
}
}
}