Skip to content

Commit 38a927c

Browse files
bchamppParidelPooya
authored andcommitted
feat(examples): update examples SAM template to have DurableConfig property (#83)
1 parent 4385048 commit 38a927c

File tree

3 files changed

+83
-33
lines changed

3 files changed

+83
-33
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function toPascalCase(filename) {
4141
*/
4242
function getExampleFiles() {
4343
const examplesDir = path.join(__dirname, '../src/examples');
44-
44+
4545
if (!fs.existsSync(examplesDir)) {
4646
throw new Error(`Examples directory not found: ${examplesDir}`);
4747
}
@@ -58,7 +58,7 @@ function getExampleFiles() {
5858
function createFunctionResource(filename) {
5959
const resourceName = toPascalCase(filename);
6060
const config = EXAMPLE_CONFIGS[filename] || DEFAULT_CONFIG;
61-
61+
6262
const functionResource = {
6363
Type: 'AWS::Serverless::Function',
6464
Properties: {
@@ -69,11 +69,14 @@ function createFunctionResource(filename) {
6969
Architectures: ['x86_64'],
7070
MemorySize: config.memorySize,
7171
Timeout: config.timeout,
72+
DurableConfig: {
73+
ExecutionTimeout: 3600,
74+
RetentionPeriodInDays: 7
75+
},
7276
Environment: {
7377
Variables: {
7478
DEX_ENDPOINT: 'http://host.docker.internal:5000',
7579
DURABLE_VERBOSE_MODE: 'true',
76-
DURABLE_RECORD_DEFINITION_MODE: 'true'
7780
}
7881
}
7982
},
@@ -95,7 +98,7 @@ function createFunctionResource(filename) {
9598
*/
9699
function generateTemplate() {
97100
const exampleFiles = getExampleFiles();
98-
101+
99102
if (exampleFiles.length === 0) {
100103
throw new Error('No TypeScript example files found in src/examples');
101104
}
@@ -122,10 +125,10 @@ function generateTemplate() {
122125
function main() {
123126
try {
124127
console.log('🔍 Scanning src/examples for TypeScript files...');
125-
128+
126129
const template = generateTemplate();
127130
const exampleCount = Object.keys(template.Resources).length;
128-
131+
129132
console.log(`📝 Found ${exampleCount} example files:`);
130133
Object.keys(template.Resources).forEach(resourceName => {
131134
const handler = template.Resources[resourceName].Properties.Handler;
@@ -143,10 +146,10 @@ function main() {
143146
// Write to template.yml
144147
const templatePath = path.join(__dirname, '../template.yml');
145148
fs.writeFileSync(templatePath, yamlContent, 'utf8');
146-
149+
147150
console.log(`✅ Generated template.yml with ${exampleCount} Lambda functions`);
148151
console.log(`📄 Template written to: ${templatePath}`);
149-
152+
150153
} catch (error) {
151154
console.error('❌ Error generating template.yml:', error.message);
152155
process.exit(1);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe('generate-template', () => {
4949
expect(resource.Properties.Environment.Variables).toEqual({
5050
DEX_ENDPOINT: 'http://host.docker.internal:5000',
5151
DURABLE_VERBOSE_MODE: 'true',
52-
DURABLE_RECORD_DEFINITION_MODE: 'true'
5352
});
5453
});
5554
});

0 commit comments

Comments
 (0)