Skip to content

chore: generate examples SAM template#526

Open
zhongkechen wants to merge 2 commits into
mainfrom
codex/generate-examples-template
Open

chore: generate examples SAM template#526
zhongkechen wants to merge 2 commits into
mainfrom
codex/generate-examples-template

Conversation

@zhongkechen

Copy link
Copy Markdown
Contributor

Summary

  • Replace the checked-in examples/template.yaml with examples/generate-template.py so the SAM template is generated from deployable Java example handlers.
  • Add source-retention @ExampleTemplate metadata for explicit template-only behavior such as Java-version conditions and OTel/X-Ray tracing, avoiding path-based special cases in the generator.
  • Generate CloudWatch log groups for every example Lambda function with RetentionInDays: 7.
  • Add a one-time unmanaged log group cleanup helper and run it before e2e sam deploy so existing Lambda-created log groups do not block CloudFormation adoption.
  • Update the e2e workflow, local build helper, README, and .gitignore for the generated template flow.

Details

  • The generator scans top-level Java classes extending DurableHandler under examples/src/main/java/software/amazon/lambda/durable/examples.
  • Function names are derived from class names using kebab-case and retain the existing FunctionNamePrefix behavior.
  • @ExampleTemplate(condition = "IsJava21OrLater") is used for the virtual-thread example.
  • @ExampleTemplate(tracing = true) is used for OTel X-Ray examples to emit Tracing: Active and the ADOT Lambda layer.
  • examples/template.yaml is now ignored and generated on demand before sam build/deploy.
  • The cleanup script is dry-run by default outside CI; CI passes --execute for the known e2e stacks. The workflow includes a TODO noting that this migration cleanup can be removed later.

Verification

  • python3 examples/generate-template.py --output /tmp/generated-template.yaml
  • custom functional comparison: generated template preserves all 40 existing Lambda functions and 40 outputs, and adds one 7-day log group per function
  • HOME=/tmp SAM_CLI_TELEMETRY=0 sam validate --lint --template-file /tmp/generated-template.yaml
  • python3 -m py_compile examples/generate-template.py
  • bash -n .github/scripts/cleanup_e2e_unmanaged_log_groups.sh
  • bash -n examples/build-and-run.sh
  • mvn spotless:apply
  • mvn -pl examples -am -DskipTests compile
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant