Skip to content

Commit 6f78dcc

Browse files
Do not replace user-provided Localstack LAMBDA_DOCKER_FLAGS (#935)
1 parent a00bbb6 commit 6f78dcc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/modules/localstack/src/localstack-container.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,19 @@ describe("LocalStackContainer", { timeout: 180_000 }, () => {
110110
expect(exitCode).toBe(0);
111111
expect(output).toContain(`${LABEL_TESTCONTAINERS_SESSION_ID}=${sessionId}`);
112112
});
113+
114+
it("should concatenate sessionId label to LAMBDA_DOCKER_FLAGS", async () => {
115+
const container = await new LocalstackContainer()
116+
.withEnvironment({
117+
LAMBDA_DOCKER_FLAGS: `-l mylabel=myvalue`,
118+
})
119+
.start();
120+
const sessionId = container.getLabels()[LABEL_TESTCONTAINERS_SESSION_ID];
121+
122+
const { output, exitCode } = await container.exec(["printenv", "LAMBDA_DOCKER_FLAGS"]);
123+
124+
expect(exitCode).toBe(0);
125+
expect(output).toContain(`${LABEL_TESTCONTAINERS_SESSION_ID}=${sessionId}`);
126+
expect(output).toContain(`mylabel=myvalue`);
127+
});
113128
});

packages/modules/localstack/src/localstack-container.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export class LocalstackContainer extends GenericContainer {
4242
private async flagLambdaSessionId(): Promise<void> {
4343
const client = await getContainerRuntimeClient();
4444
const reaper = await getReaper(client);
45-
this.withEnvironment({ LAMBDA_DOCKER_FLAGS: `-l ${LABEL_TESTCONTAINERS_SESSION_ID}=${reaper.sessionId}` });
45+
46+
this.withEnvironment({
47+
LAMBDA_DOCKER_FLAGS: `${this.environment["LAMBDA_DOCKER_FLAGS"] ?? ""} -l ${LABEL_TESTCONTAINERS_SESSION_ID}=${reaper.sessionId}`,
48+
});
4649
}
4750

4851
protected override async beforeContainerCreated(): Promise<void> {

0 commit comments

Comments
 (0)