gateway: move deployment into SAR macro - #17
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR shifts the Khone deployment model so the SAR-installed bootstrap macro owns the deployable gateway (Lambda, role/policy, Function URL, config publisher, optional log group), while application stacks only supply target Lambdas and an existing Lambda Managed Instances (LMI) capacity provider ARN. It also adds release automation to publish a versioned gateway zip and the SAR bootstrap application, and updates templates/docs/examples/benchmark tooling to match the new contract.
Changes:
- Expand
Khone::Gateway::Serviceinto a full gateway deployment surface (Lambda + IAM + URL + config publisher) instead of config-publisher-only. - Add SAR release workflow + helper scripts to build/upload the gateway artifact and publish/share the SAR app.
- Update examples, benchmark stack/tooling, website copy, and docs to remove local
CodeUri: ../../gatewayusage and reference generated resources.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| website/app/page.tsx | Updates homepage copy and YAML snippet to reflect macro-owned gateway deployment. |
| scripts/set-version.sh | Adds helper to bump repo VERSION and bootstrap template SemanticVersion. |
| scripts/render-bootstrap-release-template.py | Renders a release bootstrap template with immutable gateway artifact defaults. |
| scripts/normalize-yaml-scalar.sh | Normalizes YAML scalars for workflow metadata validation/parsing. |
| README.md | Updates deployment model and quickstart instructions for SAR/gateway artifact flow. |
| Makefile | Adds bootstrap deploy parameters for gateway artifact S3 coordinates. |
| examples/sam/templates/native-batch-node/template.yaml | Migrates example from explicit gateway Lambda to Khone::Gateway::Service properties + new outputs. |
| examples/sam/templates/layer-proxy-python/template.yaml | Same migration for Python layer-proxy example. |
| examples/sam/templates/layer-proxy-node/template.yaml | Same migration for Node layer-proxy example. |
| examples/sam/templates/adapter-rust/template.yaml | Same migration for Rust adapter example. |
| examples/sam/templates/adapter-node/template.yaml | Same migration for Node adapter example. |
| docs/start/quickstart.md | Updates bootstrap steps to include SAR install or artifact upload for source bootstrap deploys. |
| docs/reference/configuration.md | Updates KHONE_CONFIG_URI wiring description and clarifies intrinsic x-target-lambda support. |
| docs/reference/bootstrap-macro.md | Documents the new gateway resource contract and generated logical IDs. |
| docs/deploy/sam-gateway.md | Updates “SAM gateway” guide to the macro-owned gateway model and new outputs/permissions behavior. |
| docs/deploy/release.md | Adds release documentation for SAR + gateway artifact publishing workflow. |
| docs/deploy/lmi-deployment-model.md | Updates architecture/deployment model to reflect macro-owned gateway Lambda. |
| docs/deploy/index.md | Adds links for SAR bootstrap install and release docs; updates descriptions. |
| docs/deploy/examples.md | Updates example deployment prerequisites/notes for SAR artifact settings. |
| docs/deploy/bootstrap-sar.md | Adds SAR installation guide for the bootstrap application. |
| bootstrap/tests/test_gateway_macro.py | Expands macro unit tests to validate generated Lambda/IAM/URL/log group resources and validations. |
| bootstrap/template.yaml | Adds SAR application metadata and gateway artifact parameters wired into macro Lambda env vars. |
| bootstrap/README.md | Updates bootstrap README for SAR defaults vs source-deploy parameter passing. |
| bootstrap/gateway_macro/app.py | Implements macro expansion into Lambda gateway resources + IAM policy generation and validations. |
| benchmark/test/report.test.ts | Updates expected gateway logical ID from GatewayFunction to GatewayService. |
| benchmark/test/render.test.ts | Updates expected gateway logical ID for chart title context. |
| benchmark/src/charts/echarts/specs.ts | Updates gateway metadata lookup key to GatewayService. |
| benchmark/sam/template.yaml | Migrates benchmark stack from explicit gateway Lambda to Khone::Gateway::Service + updated outputs/targets. |
| .gitignore | Ignores generated release artifacts (bootstrap/template.release.yaml, /release/). |
| .github/workflows/publish-release.yml | Adds release workflow to build/upload gateway zip, package/publish SAR app, and optionally org-share it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alessandrobologna
marked this pull request as ready for review
May 26, 2026 01:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16
Summary
This changes
Khone::Gateway::Servicefrom a config-publisher-only macro resource into the deployable gateway resource. Application stacks still bring their own Lambda Managed Instances capacity provider ARN, but the macro now owns the gateway Lambda, execution role/policy, Function URL, config publisher, and optional log group.The bootstrap app is prepared for SAR installation: release automation builds the arm64 gateway zip, uploads it to a versioned S3 key, renders the bootstrap template with that artifact location, packages the SAR application, publishes it, and can privately share it with the AWS Organization.
Background
The previous deployment model required every consumer stack to carry the gateway source path and define a local
GatewayFunctionblock. That made examples and benchmark stacks depend onCodeUri: ../../gateway, duplicated IAM/Function URL wiring, and made versioned gateway rollout a consumer concern.This moves the versioned gateway package into the SAR-installed bootstrap/macro layer while keeping capacity management external and explicit.
What Changed
Khone::Gateway::Servicenow expands into anAWS::Lambda::Functionunder the original logical ID.<Gateway>KhoneConfigPublisher<Gateway>KhoneExecutionRole<Gateway>KhoneFunctionUrl<Gateway>KhoneFunctionUrlPermissionfor public Function URLs<Gateway>KhoneLogGroupwhen retention is configuredSpec.paths.*.*.x-target-lambda.bootstrap/template.yamlnow includes SAR metadata and gateway artifact parameters consumed by the macro Lambda environment.publish-release.yml.Workflow Event Flow
publish-release.ymlruns onpushtags matchingv*and on manualworkflow_dispatchwithrelease_tagandshare_scopeinputs.For tag pushes, the workflow checks out
GITHUB_SHA; for manual runs, it checks outrefs/tags/<release_tag>. The job haspermissions: { contents: read, id-token: write }, usesactions/checkoutwithpersist-credentials: false, and assumes the configured AWS role through OIDC.The release path validates
VERSIONandbootstrap/template.yamlSemanticVersion, builds the gateway zip, uploads it tokhone/releases/<version>/gateway/bootstrap.zip, captures the S3 object version when available, rendersbootstrap/template.release.yaml, runssam validate,sam build,sam package, thensam publishwith the exact semantic version.For
share_scope=organization, the workflow reads the existing SAR application policy, replaces only theshare-orgstatement, and writes the merged policy back so unrelated sharing statements are preserved.Expected rerun behavior: rerunning the same semantic version after a successful
sam publishmay fail because SAR versions are immutable; artifact upload uses a versioned key and object version when the bucket supports it. Partial failures beforesam publishcan be rerun for the same tag after fixing the failure condition.Validation
python3 -m unittest bootstrap/tests/test_gateway_macro.py bootstrap/tests/test_config_publisher.pycargo lambda build --release --arm64 --output-format zip -p khone-gatewaysam validate --template-file bootstrap/template.yaml --lintsam build --template-file bootstrap/template.yamlactionlint .github/workflows/publish-release.ymlbash -n scripts/normalize-yaml-scalar.sh scripts/set-version.shshellcheck scripts/normalize-yaml-scalar.sh scripts/set-version.shpython3 -m py_compile scripts/render-bootstrap-release-template.pynpm ci --prefix benchmark --ignore-scriptsnpm test --prefix benchmarkjqSAR policy-merge simulationkhone-bootstrapandadapter-nodewith an existing LMI capacity provider; verified generated resources, Lambda LMI config, Function URL, and HTTP 200 responses for buffered and streaming routes