Skip to content

Commit 32b4d7c

Browse files
anthonytingParidelPooya
authored andcommitted
chore: remove DEX-specific environment variables (#94)
*Issue #, if available:* DAR-SDK-315 *Description of changes:* Removing DEX-specific environment variables: - DURABLE_LOCAL_MODE - DEX_REGION - DEX_ENDPOINT - DURABLE_RECORD_DEFINITION_MODE Changes: - Mocking will now be allowed outside local mode (we can change or remove this later) - Test library will now use the "LocalRunner" field in the invocation event to configure the API client. - DEX_REGION is no longer used, and customers must set AWS_REGION - DEX_ENDPOINT is no longer used, and customers can use AWS_ENDPOINT_URL_LAMBDA or AWS_ENDPOINT_URL. It will default to the default Lambda endpoint based on the region. - Local runner will use these environment variables: `DURABLE_LOCAL_RUNNER_ENDPOINT` and `DURABLE_LOCAL_RUNNER_REGION`. These variables will not be used when the "LocalRunner" field is not provided. This is to not conflict with any AWS_REGION and AWS_ENDPOINT_URL that they may have in their test code. Currently the DEX environment variables that exist: - DURABLE_VERBOSE_MODE - DURABLE_LOCAL_RUNNER_ENDPOINT (only in local mode) - DURABLE_LOCAL_RUNNER_REGION (only in local mode) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 10ad3cc commit 32b4d7c

38 files changed

+230
-400
lines changed

.github/workflows/scripts/integration-test/integration-test.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { join, dirname } from "path";
66
import { fileURLToPath } from "url";
77

88
import examplesCatalog from "../../../../packages/aws-durable-execution-sdk-js-examples/examples-catalog.json" with { type: "json" };
9-
import { LambdaClient, DeleteFunctionCommand } from "@aws-sdk/client-lambda";
9+
import {
10+
LambdaClient,
11+
DeleteFunctionCommand,
12+
ResourceNotFoundException,
13+
} from "@aws-sdk/client-lambda";
1014

1115
// Colors for output
1216
const COLORS = {
@@ -270,7 +274,15 @@ class IntegrationTestRunner {
270274
FunctionName: functionName,
271275
});
272276

273-
await lambdaClient.send(deleteCommand);
277+
try {
278+
await lambdaClient.send(deleteCommand);
279+
} catch (error) {
280+
if (error instanceof ResourceNotFoundException) {
281+
log.warning(`Function not found: ${functionName}`);
282+
continue;
283+
}
284+
throw error;
285+
}
274286
log.success(`Deleted function: ${functionName}`);
275287
}
276288
}

packages/aws-durable-execution-sdk-js-examples/scripts/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ All Lambda functions get these default settings unless overridden:
5252
- **Runtime**: nodejs22.x
5353
- **Architecture**: x86_64
5454
- **Environment Variables**:
55-
- `DEX_ENDPOINT`: `http://host.docker.internal:5000`
55+
- `AWS_ENDPOINT_URL_LAMBDA`: `http://host.docker.internal:5000`
5656
- `DURABLE_VERBOSE_MODE`: `true`
57-
- `DURABLE_RECORD_DEFINITION_MODE`: `true`
5857

5958
### Adding New Examples
6059

packages/aws-durable-execution-sdk-js-examples/scripts/deploy-lambda.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ if aws lambda get-function --function-name "$FUNCTION_NAME" --endpoint-url "$LAM
101101
echo "Updating environment variables..."
102102
aws lambda update-function-configuration \
103103
--function-name "$FUNCTION_NAME" \
104-
--environment Variables="{DEX_ENDPOINT=$LAMBDA_ENDPOINT}" \
104+
--environment Variables="{AWS_ENDPOINT_URL_LAMBDA=$LAMBDA_ENDPOINT}" \
105105
--kms-key-arn "$KMS_KEY_ARN" \
106106
--endpoint-url "$LAMBDA_ENDPOINT" \
107107
--region "$AWS_REGION" \
@@ -132,7 +132,7 @@ else
132132
--durable-config RetentionPeriodInDays=$RETENTION_DAYS,ExecutionTimeout=$EXECUTION_TIMEOUT \
133133
--timeout 60 \
134134
--memory-size 128 \
135-
--environment Variables="{DEX_ENDPOINT=$LAMBDA_ENDPOINT}" \
135+
--environment Variables="{AWS_ENDPOINT_URL_LAMBDA=$LAMBDA_ENDPOINT}" \
136136
--kms-key-arn "$KMS_KEY_ARN" \
137137
--endpoint-url "$LAMBDA_ENDPOINT" \
138138
--region "$AWS_REGION" \

packages/aws-durable-execution-sdk-js-examples/scripts/generate-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function createFunctionResource(filename) {
7575
},
7676
Environment: {
7777
Variables: {
78-
DEX_ENDPOINT: 'http://host.docker.internal:5000',
78+
AWS_ENDPOINT_URL_LAMBDA: 'http://host.docker.internal:5000',
7979
DURABLE_VERBOSE_MODE: 'true',
8080
}
8181
}

packages/aws-durable-execution-sdk-js-examples/src/__tests__/generate-template.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('generate-template', () => {
4747
const resource = createFunctionResource('hello-world');
4848

4949
expect(resource.Properties.Environment.Variables).toEqual({
50-
DEX_ENDPOINT: 'http://host.docker.internal:5000',
50+
AWS_ENDPOINT_URL_LAMBDA: 'http://host.docker.internal:5000',
5151
DURABLE_VERBOSE_MODE: 'true',
5252
});
5353
});

packages/aws-durable-execution-sdk-js-examples/template.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Resources:
1919
RetentionPeriodInDays: 7
2020
Environment:
2121
Variables:
22-
DEX_ENDPOINT: http://host.docker.internal:5000
22+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
2323
DURABLE_VERBOSE_MODE: 'true'
2424
Metadata:
2525
SkipBuild: 'True'
@@ -39,7 +39,7 @@ Resources:
3939
RetentionPeriodInDays: 7
4040
Environment:
4141
Variables:
42-
DEX_ENDPOINT: http://host.docker.internal:5000
42+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
4343
DURABLE_VERBOSE_MODE: 'true'
4444
Metadata:
4545
SkipBuild: 'True'
@@ -59,7 +59,7 @@ Resources:
5959
RetentionPeriodInDays: 7
6060
Environment:
6161
Variables:
62-
DEX_ENDPOINT: http://host.docker.internal:5000
62+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
6363
DURABLE_VERBOSE_MODE: 'true'
6464
Metadata:
6565
SkipBuild: 'True'
@@ -79,7 +79,7 @@ Resources:
7979
RetentionPeriodInDays: 7
8080
Environment:
8181
Variables:
82-
DEX_ENDPOINT: http://host.docker.internal:5000
82+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
8383
DURABLE_VERBOSE_MODE: 'true'
8484
Metadata:
8585
SkipBuild: 'True'
@@ -99,7 +99,7 @@ Resources:
9999
RetentionPeriodInDays: 7
100100
Environment:
101101
Variables:
102-
DEX_ENDPOINT: http://host.docker.internal:5000
102+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
103103
DURABLE_VERBOSE_MODE: 'true'
104104
Metadata:
105105
SkipBuild: 'True'
@@ -119,7 +119,7 @@ Resources:
119119
RetentionPeriodInDays: 7
120120
Environment:
121121
Variables:
122-
DEX_ENDPOINT: http://host.docker.internal:5000
122+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
123123
DURABLE_VERBOSE_MODE: 'true'
124124
Metadata:
125125
SkipBuild: 'True'
@@ -139,7 +139,7 @@ Resources:
139139
RetentionPeriodInDays: 7
140140
Environment:
141141
Variables:
142-
DEX_ENDPOINT: http://host.docker.internal:5000
142+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
143143
DURABLE_VERBOSE_MODE: 'true'
144144
Metadata:
145145
SkipBuild: 'True'
@@ -159,7 +159,7 @@ Resources:
159159
RetentionPeriodInDays: 7
160160
Environment:
161161
Variables:
162-
DEX_ENDPOINT: http://host.docker.internal:5000
162+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
163163
DURABLE_VERBOSE_MODE: 'true'
164164
Metadata:
165165
SkipBuild: 'True'
@@ -179,7 +179,7 @@ Resources:
179179
RetentionPeriodInDays: 7
180180
Environment:
181181
Variables:
182-
DEX_ENDPOINT: http://host.docker.internal:5000
182+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
183183
DURABLE_VERBOSE_MODE: 'true'
184184
Metadata:
185185
SkipBuild: 'True'
@@ -199,7 +199,7 @@ Resources:
199199
RetentionPeriodInDays: 7
200200
Environment:
201201
Variables:
202-
DEX_ENDPOINT: http://host.docker.internal:5000
202+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
203203
DURABLE_VERBOSE_MODE: 'true'
204204
Metadata:
205205
SkipBuild: 'True'
@@ -219,7 +219,7 @@ Resources:
219219
RetentionPeriodInDays: 7
220220
Environment:
221221
Variables:
222-
DEX_ENDPOINT: http://host.docker.internal:5000
222+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
223223
DURABLE_VERBOSE_MODE: 'true'
224224
Metadata:
225225
SkipBuild: 'True'
@@ -239,7 +239,7 @@ Resources:
239239
RetentionPeriodInDays: 7
240240
Environment:
241241
Variables:
242-
DEX_ENDPOINT: http://host.docker.internal:5000
242+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
243243
DURABLE_VERBOSE_MODE: 'true'
244244
Metadata:
245245
SkipBuild: 'True'
@@ -259,7 +259,7 @@ Resources:
259259
RetentionPeriodInDays: 7
260260
Environment:
261261
Variables:
262-
DEX_ENDPOINT: http://host.docker.internal:5000
262+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
263263
DURABLE_VERBOSE_MODE: 'true'
264264
Metadata:
265265
SkipBuild: 'True'
@@ -279,7 +279,7 @@ Resources:
279279
RetentionPeriodInDays: 7
280280
Environment:
281281
Variables:
282-
DEX_ENDPOINT: http://host.docker.internal:5000
282+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
283283
DURABLE_VERBOSE_MODE: 'true'
284284
Metadata:
285285
SkipBuild: 'True'
@@ -299,7 +299,7 @@ Resources:
299299
RetentionPeriodInDays: 7
300300
Environment:
301301
Variables:
302-
DEX_ENDPOINT: http://host.docker.internal:5000
302+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
303303
DURABLE_VERBOSE_MODE: 'true'
304304
Metadata:
305305
SkipBuild: 'True'
@@ -319,7 +319,7 @@ Resources:
319319
RetentionPeriodInDays: 7
320320
Environment:
321321
Variables:
322-
DEX_ENDPOINT: http://host.docker.internal:5000
322+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
323323
DURABLE_VERBOSE_MODE: 'true'
324324
Metadata:
325325
SkipBuild: 'True'
@@ -339,7 +339,7 @@ Resources:
339339
RetentionPeriodInDays: 7
340340
Environment:
341341
Variables:
342-
DEX_ENDPOINT: http://host.docker.internal:5000
342+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
343343
DURABLE_VERBOSE_MODE: 'true'
344344
Metadata:
345345
SkipBuild: 'True'
@@ -359,7 +359,7 @@ Resources:
359359
RetentionPeriodInDays: 7
360360
Environment:
361361
Variables:
362-
DEX_ENDPOINT: http://host.docker.internal:5000
362+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
363363
DURABLE_VERBOSE_MODE: 'true'
364364
Metadata:
365365
SkipBuild: 'True'
@@ -379,7 +379,7 @@ Resources:
379379
RetentionPeriodInDays: 7
380380
Environment:
381381
Variables:
382-
DEX_ENDPOINT: http://host.docker.internal:5000
382+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
383383
DURABLE_VERBOSE_MODE: 'true'
384384
Metadata:
385385
SkipBuild: 'True'
@@ -399,7 +399,7 @@ Resources:
399399
RetentionPeriodInDays: 7
400400
Environment:
401401
Variables:
402-
DEX_ENDPOINT: http://host.docker.internal:5000
402+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
403403
DURABLE_VERBOSE_MODE: 'true'
404404
Policies:
405405
- DynamoDBReadPolicy:
@@ -422,7 +422,7 @@ Resources:
422422
RetentionPeriodInDays: 7
423423
Environment:
424424
Variables:
425-
DEX_ENDPOINT: http://host.docker.internal:5000
425+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
426426
DURABLE_VERBOSE_MODE: 'true'
427427
Metadata:
428428
SkipBuild: 'True'
@@ -442,7 +442,7 @@ Resources:
442442
RetentionPeriodInDays: 7
443443
Environment:
444444
Variables:
445-
DEX_ENDPOINT: http://host.docker.internal:5000
445+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
446446
DURABLE_VERBOSE_MODE: 'true'
447447
Metadata:
448448
SkipBuild: 'True'
@@ -462,7 +462,7 @@ Resources:
462462
RetentionPeriodInDays: 7
463463
Environment:
464464
Variables:
465-
DEX_ENDPOINT: http://host.docker.internal:5000
465+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
466466
DURABLE_VERBOSE_MODE: 'true'
467467
Metadata:
468468
SkipBuild: 'True'
@@ -482,7 +482,7 @@ Resources:
482482
RetentionPeriodInDays: 7
483483
Environment:
484484
Variables:
485-
DEX_ENDPOINT: http://host.docker.internal:5000
485+
AWS_ENDPOINT_URL_LAMBDA: http://host.docker.internal:5000
486486
DURABLE_VERBOSE_MODE: 'true'
487487
Metadata:
488488
SkipBuild: 'True'

packages/aws-durable-execution-sdk-js-testing/src/checkpoint-server/__tests__/checkpoint-server.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ describe("checkpoint-server", () => {
7272
server = await startCheckpointServer(TEST_PORT);
7373
});
7474

75-
afterEach(() => {
76-
server.close();
75+
afterEach(async () => {
76+
server.closeAllConnections();
77+
await new Promise((resolve) => server.close(resolve));
7778
});
7879

7980
describe("startCheckpointServer", () => {

packages/aws-durable-execution-sdk-js-testing/src/test-runner/local/__tests__/integration/local-durable-test-runner.integration.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ afterAll(() => LocalDurableTestRunner.teardownTestEnvironment());
1313
* without mocking core dependencies.
1414
*/
1515
describe("LocalDurableTestRunner Integration", () => {
16+
const originalEnv = process.env;
17+
18+
afterEach(() => {
19+
process.env = originalEnv;
20+
});
21+
22+
it("should complete execution with no environment variables set", async () => {
23+
process.env = {};
24+
25+
const handler = withDurableFunctions(
26+
async (event: unknown, context: DurableContext) => {
27+
const result = await context.step(() => Promise.resolve("completed"));
28+
return { success: true, step: result };
29+
}
30+
);
31+
32+
const runner = new LocalDurableTestRunner({
33+
handlerFunction: handler,
34+
skipTime: true,
35+
});
36+
37+
const result = await runner.run();
38+
39+
expect(result.getResult()).toEqual({
40+
success: true,
41+
step: "completed",
42+
});
43+
});
44+
1645
it("should complete execution with wait operations", async () => {
1746
const handler = withDurableFunctions(
1847
async (event: unknown, context: DurableContext) => {

packages/aws-durable-execution-sdk-js-testing/src/test-runner/local/__tests__/invoke-handler.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe("invoke-handler", () => {
5151
Operations: params.operations,
5252
NextMarker: "",
5353
},
54+
LocalRunner: true,
5455
},
5556
expect.objectContaining({
5657
functionName: "my-function-name",

packages/aws-durable-execution-sdk-js-testing/src/test-runner/local/__tests__/local-durable-test-runner.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ describe("LocalDurableTestRunner", () => {
102102
);
103103
});
104104

105+
beforeEach(() => {
106+
delete process.env.DURABLE_LOCAL_RUNNER_REGION;
107+
delete process.env.DURABLE_LOCAL_RUNNER_ENDPOINT;
108+
delete process.env.DURABLE_LOCAL_RUNNER_CREDENTIALS;
109+
});
110+
111+
afterEach(() => {
112+
delete process.env.DURABLE_LOCAL_RUNNER_REGION;
113+
delete process.env.DURABLE_LOCAL_RUNNER_ENDPOINT;
114+
delete process.env.DURABLE_LOCAL_RUNNER_CREDENTIALS;
115+
});
116+
105117
describe("constructor", () => {
106118
it("should initialize with required dependencies", () => {
107119
const runner = new LocalDurableTestRunner<{ success: boolean }>({
@@ -148,8 +160,23 @@ describe("LocalDurableTestRunner", () => {
148160
handlerFunction: mockHandlerFunction,
149161
});
150162

163+
expect(process.env.DURABLE_LOCAL_RUNNER_REGION).toBeUndefined();
164+
expect(process.env.DURABLE_LOCAL_RUNNER_ENDPOINT).toBeUndefined();
165+
expect(process.env.DURABLE_LOCAL_RUNNER_CREDENTIALS).toBeUndefined();
166+
151167
await runner.run();
152168

169+
expect(process.env.DURABLE_LOCAL_RUNNER_REGION).toBe("us-west-2");
170+
expect(process.env.DURABLE_LOCAL_RUNNER_ENDPOINT).toBe(
171+
"http://127.0.0.1:1234"
172+
);
173+
expect(JSON.parse(process.env.DURABLE_LOCAL_RUNNER_CREDENTIALS!)).toEqual(
174+
{
175+
accessKeyId: "placeholder-accessKeyId",
176+
secretAccessKey: "placeholder-secretAccessKey",
177+
sessionToken: "placeholder-sessionToken",
178+
}
179+
);
153180
expect(mockOrchestrator.executeHandler).toHaveBeenCalledWith(undefined);
154181
});
155182

0 commit comments

Comments
 (0)