apx-aws-lambda 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/PKG-INFO +2 -2
  2. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/README.md +1 -1
  3. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/lambda_.py +12 -8
  4. apx_aws_lambda-0.5.0/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +9 -0
  5. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +1 -1
  6. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +11 -9
  7. apx_aws_lambda-0.5.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/Makefile +5 -0
  8. {apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java → apx_aws_lambda-0.5.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}}/template.yaml +26 -6
  9. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda.egg-info/PKG-INFO +2 -2
  10. apx_aws_lambda-0.5.0/apx_aws_lambda.egg-info/SOURCES.txt +28 -0
  11. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/pyproject.toml +1 -1
  12. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/tests/test_proxy.py +1 -1
  13. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/tests/test_targets.py +2 -0
  14. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -30
  15. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/Makefile +0 -6
  16. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/cmd/lambda/main.go +0 -25
  17. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/template.yaml +0 -97
  18. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/Makefile +0 -7
  19. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/run.sh +0 -2
  20. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/Makefile +0 -7
  21. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/run.sh +0 -2
  22. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/template.yaml +0 -105
  23. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/Makefile +0 -11
  24. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/run.sh +0 -2
  25. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/template.yaml +0 -102
  26. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -21
  27. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -21
  28. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/template.yaml +0 -110
  29. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -93
  30. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/Makefile +0 -19
  31. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/lambda_handler.rb +0 -70
  32. apx_aws_lambda-0.4.0/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/template.yaml +0 -99
  33. apx_aws_lambda-0.4.0/apx_aws_lambda.egg-info/SOURCES.txt +0 -45
  34. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/LICENSE +0 -0
  35. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/__init__.py +0 -0
  36. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/cli.py +0 -0
  37. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
  38. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
  39. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
  40. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
  41. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/overlays/index.json +0 -0
  42. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/plugin.py +0 -0
  43. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/proxy.py +0 -0
  44. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/shell.py +0 -0
  45. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda/tools.py +0 -0
  46. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
  47. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
  48. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda.egg-info/requires.txt +0 -0
  49. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/apx_aws_lambda.egg-info/top_level.txt +0 -0
  50. {apx_aws_lambda-0.4.0 → apx_aws_lambda-0.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: AWS Lambda for Action Platform: the aws/lambda deploy target (SAM) with its overlay, and tools to read stacks and functions.
5
5
  Author-email: Action Platform <cloud@actionplatform.io>
6
6
  License-Expression: Apache-2.0
@@ -47,7 +47,7 @@ action-platform diagnose
47
47
 
48
48
  | | |
49
49
  |---|---|
50
- | Overlay | `template.yaml`, `samconfig.toml`, `Makefile` and the language's entry point — `lambda_handler.py` (Mangum) for Python, `run.sh` behind the Lambda Web Adapter layer for Node and Spring (Java, Kotlin), `cmd/lambda/main.go` (`-tags lambda`) for Go, `lambda_handler.rb` (a Rack call, no server) for Ruby —, `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional). Every `web/*` template of the official repository deploys; the health route is `/health` (API Gateway keeps `/ping` for itself on `execute-api`) |
50
+ | Overlay | `template.yaml`, `samconfig.toml`, a one-line `Makefile` (`ap-build package`), `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional). One template for every language: the Lambda Web Adapter layer runs the project as an HTTP server on `$PORT` — `run.sh` from `ap-build` (Python `python3.12`, Node `nodejs22.x`, Java/Kotlin `java21`, Ruby `ruby3.3`) or the static `bootstrap` on `provided.al2023` (Go). Every `web/*` template of the official repository deploys; the health route is `/health` (API Gateway keeps `/ping` for itself on `execute-api`) |
51
51
  | Readiness | before a deploy, without building or changing anything: the tooling is there, the overlay is applied, the stack name resolves, the credentials work, the stack is not mid-operation or failed (a `ROLLBACK_COMPLETE` first creation is a warning — the deploy deletes it), the deploy role may do what the template needs (simulated with `iam:SimulatePrincipalPolicy` against the stack, the function, its log group, the execution role and every public layer the template references — the Lambda Web Adapter's, for one) and `sam validate --lint` passes. The platform runs it after every release for `dev` and `prod` and refuses a blocked deploy unless forced; `action-platform readiness` runs it on a machine |
52
52
  | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
53
53
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
@@ -27,7 +27,7 @@ action-platform diagnose
27
27
 
28
28
  | | |
29
29
  |---|---|
30
- | Overlay | `template.yaml`, `samconfig.toml`, `Makefile` and the language's entry point — `lambda_handler.py` (Mangum) for Python, `run.sh` behind the Lambda Web Adapter layer for Node and Spring (Java, Kotlin), `cmd/lambda/main.go` (`-tags lambda`) for Go, `lambda_handler.rb` (a Rack call, no server) for Ruby —, `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional). Every `web/*` template of the official repository deploys; the health route is `/health` (API Gateway keeps `/ping` for itself on `execute-api`) |
30
+ | Overlay | `template.yaml`, `samconfig.toml`, a one-line `Makefile` (`ap-build package`), `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional). One template for every language: the Lambda Web Adapter layer runs the project as an HTTP server on `$PORT` — `run.sh` from `ap-build` (Python `python3.12`, Node `nodejs22.x`, Java/Kotlin `java21`, Ruby `ruby3.3`) or the static `bootstrap` on `provided.al2023` (Go). Every `web/*` template of the official repository deploys; the health route is `/health` (API Gateway keeps `/ping` for itself on `execute-api`) |
31
31
  | Readiness | before a deploy, without building or changing anything: the tooling is there, the overlay is applied, the stack name resolves, the credentials work, the stack is not mid-operation or failed (a `ROLLBACK_COMPLETE` first creation is a warning — the deploy deletes it), the deploy role may do what the template needs (simulated with `iam:SimulatePrincipalPolicy` against the stack, the function, its log group, the execution role and every public layer the template references — the Lambda Web Adapter's, for one) and `sam validate --lint` passes. The platform runs it after every release for `dev` and `prod` and refuses a blocked deploy unless forced; `action-platform readiness` runs it on a machine |
32
32
  | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
33
33
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
@@ -112,21 +112,25 @@ class LambdaTarget(DeployTarget):
112
112
  return stack
113
113
 
114
114
  def _overrides(self, ctx: Context, env: dict[str, str] | None) -> list[str]:
115
- """`--parameter-overrides`: the stage's own from samconfig.toml, plus the execution role the proxy granted — the CLI flag replaces the file's, so both go together."""
116
- role = (env or {}).get("AP_EXECUTION_ROLE")
117
-
118
- if not role:
119
- return []
120
-
115
+ """`--parameter-overrides`: the stage's own from samconfig.toml, then Stage set to the scope's name and the execution role the proxy granted — the CLI flag replaces the file's, so they all go together."""
121
116
  params = (
122
117
  self._samconfig(ctx)
123
118
  .get(self._stage(ctx), {})
124
119
  .get("deploy", {})
125
120
  .get("parameters", {})
126
121
  )
127
- own = params.get("parameter_overrides") or ""
122
+ own = [
123
+ item
124
+ for item in str(params.get("parameter_overrides") or "").split()
125
+ if not item.startswith(("Stage=", "ExecutionRoleArn="))
126
+ ]
127
+ own.append(f"Stage={ctx.stage}")
128
+ role = (env or {}).get("AP_EXECUTION_ROLE")
129
+
130
+ if role:
131
+ own.append(f"ExecutionRoleArn={role}")
128
132
 
129
- return ["--parameter-overrides", f"{own} ExecutionRoleArn={role}".strip()]
133
+ return ["--parameter-overrides", " ".join(own)]
130
134
 
131
135
  def _region(self, ctx: Context) -> str | None:
132
136
  params = (
@@ -0,0 +1,9 @@
1
+ """Cloud overlay post-gen: keep the deploy workflow only for the CI it belongs to."""
2
+
3
+ import shutil
4
+ from pathlib import Path
5
+
6
+ CI = "{{ cookiecutter.ci }}"
7
+
8
+ if CI != "github" and Path(".github").exists():
9
+ shutil.rmtree(".github")
@@ -56,7 +56,7 @@ jobs:
56
56
  python-version: "3.12"
57
57
 
58
58
  - if: steps.gate.outputs.ready == 'true'
59
- run: pip install aws-sam-cli
59
+ run: pip install aws-sam-cli "ap-build @ git+https://github.com/actionplatform/images-base@master"
60
60
 
61
61
  - if: steps.gate.outputs.ready == 'true'
62
62
  run: sam build
@@ -1,14 +1,16 @@
1
1
  # Deploy — AWS Lambda (SAM)
2
2
 
3
- Overlay `cloud/aws/lambda`. The app runs on Lambda (arm64) behind an HTTP API Gateway; `sam build` follows the `Makefile` the overlay left for the language:
3
+ Overlay `cloud/aws/lambda`. The app runs on Lambda (arm64) behind an HTTP API Gateway, the same way in every language: the **Lambda Web Adapter** layer starts the app as an HTTP server on `$PORT` (8080) and proxies the API Gateway events to it. `sam build` follows the one-line `Makefile` the overlay left — `ap-build package` — which assembles the app, its dependencies and `run.sh` (`exec <start command>`) into the function's artifact:
4
4
 
5
- | Language | Runtime | How the app is served |
6
- |---|---|---|
7
- | Python | `python3.12` | `lambda_handler.py` — Mangum wraps `app.create_app()`; dependencies build into a layer from wheels |
8
- | Node | `nodejs22.x` | the Lambda Web Adapter layer runs `run.sh` (`node dist/server.js`) and proxies HTTP to port 8080 |
9
- | Java, Kotlin | `java17` | the Lambda Web Adapter layer runs `run.sh` (`java -jar app.jar`), readiness on `/health` |
10
- | Go | `provided.al2023` | `cmd/lambda/main.go` (`-tags lambda`) — the gin engine behind `aws-lambda-go-api-proxy`, one static `bootstrap` |
11
- | Ruby | `ruby3.3` | `lambda_handler.rb` — the Rack app from `app.rb` called straight from the API Gateway event, no server |
5
+ | Language | Runtime | `ap-build package` | `run.sh` |
6
+ |---|---|---|---|
7
+ | Python | `python3.12` | the project's wheel and its dependencies, built for arm64 | `uvicorn app:app --port $PORT` |
8
+ | Node | `nodejs22.x` | `dist/` and the pruned `node_modules` | `node dist/server.js` |
9
+ | Java, Kotlin | `java21` | `target/*.jar` as `app.jar` | `java -jar app.jar --server.port=$PORT` |
10
+ | Go | `provided.al2023` | one static binary named `bootstrap` from `./cmd/server` | — the binary itself; the adapter runs as an extension |
11
+ | Ruby | `ruby3.3` | the app and `vendor/bundle` without development/test gems | `rackup -s webrick -p $PORT` |
12
+
13
+ `[build] start` (or `[build] package`, `[build] main`) in `platform.toml` overrides the language's default. `ap-build` comes with the platform's worker and with the `build-<language>` images; `pip install ap-build` puts it on a machine.
12
14
 
13
15
  The route is `/health` — API Gateway reserves `/ping` on `execute-api` and answers it itself.
14
16
 
@@ -22,7 +24,7 @@ sam deploy # dev stack
22
24
  sam deploy --config-env prod # prod stack
23
25
  ```
24
26
 
25
- Through the platform's deploy proxy the stack is named `ap-<org>-<project>-<app>-<dev|prod>` and `--stack-name` is set by the target; `samconfig.toml`'s `stack_name` only matters for a deploy from a machine.
27
+ Through the platform's deploy proxy the stack is named `ap-<org>-<project>-<app>-<scope>` (`Stage` takes the scope's name) and `--stack-name` is set by the target; `samconfig.toml`'s `stack_name` only matters for a deploy from a machine.
26
28
 
27
29
  ## CI
28
30
 
@@ -0,0 +1,5 @@
1
+ # SAM build recipe (BuildMethod: makefile): ap-build assembles the app, its dependencies and run.sh
2
+ # (bootstrap for Go) for the Lambda Web Adapter — the same recipe for every language.
3
+
4
+ build-ApiFunction:
5
+ AP_ARTIFACTS="$(ARTIFACTS_DIR)" ap-build package
@@ -1,11 +1,10 @@
1
1
  AWSTemplateFormatVersion: '2010-09-09'
2
2
  Transform: AWS::Serverless-2016-10-31
3
- Description: {{ cookiecutter.project_slug }} — Spring Boot app on Lambda (Lambda Web Adapter) behind an HTTP API
3
+ Description: {{ cookiecutter.project_slug }} — {{ cookiecutter.language }} web app on Lambda (Lambda Web Adapter) behind an HTTP API
4
4
 
5
5
  Parameters:
6
6
  Stage:
7
7
  Type: String
8
- AllowedValues: [dev, prod]
9
8
  Default: dev
10
9
  DomainName:
11
10
  Type: String
@@ -28,7 +27,11 @@ Conditions:
28
27
  Globals:
29
28
  Function:
30
29
  Timeout: 30
30
+ {%- if cookiecutter.language in ["java", "kotlin"] %}
31
31
  MemorySize: 1024
32
+ {%- else %}
33
+ MemorySize: 512
34
+ {%- endif %}
32
35
  Architectures: [arm64]
33
36
 
34
37
  Resources:
@@ -42,20 +45,37 @@ Resources:
42
45
  Properties:
43
46
  FunctionName: !Sub "${AWS::StackName}-api"
44
47
  CodeUri: .
48
+ {%- if cookiecutter.language == "go" %}
49
+ Handler: bootstrap
50
+ Runtime: provided.al2023
51
+ {%- else %}
45
52
  Handler: run.sh
46
- Runtime: java17
53
+ {%- if cookiecutter.language == "python" %}
54
+ Runtime: python3.12
55
+ {%- elif cookiecutter.language == "node" %}
56
+ Runtime: nodejs22.x
57
+ {%- elif cookiecutter.language == "ruby" %}
58
+ Runtime: ruby3.3
59
+ {%- else %}
60
+ Runtime: java21
61
+ {%- endif %}
62
+ {%- endif %}
47
63
  Role: !If [HasExecutionRole, !Ref ExecutionRoleArn, !Ref AWS::NoValue]
48
64
  Layers:
49
65
  - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:25
50
66
  Environment:
51
67
  Variables:
52
- SCOPE: !If [IsProd, production, development]
53
- AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap
54
- AWS_LWA_PORT: "8080"
68
+ SCOPE: !Ref Stage
55
69
  PORT: "8080"
70
+ AWS_LWA_PORT: "8080"
56
71
  AWS_LWA_READINESS_CHECK_PATH: /health
72
+ {%- if cookiecutter.language != "go" %}
73
+ AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap
74
+ {%- endif %}
75
+ {%- if cookiecutter.language in ["java", "kotlin"] %}
57
76
  AWS_LWA_ASYNC_INIT: "true"
58
77
  JAVA_TOOL_OPTIONS: -XX:+TieredCompilation -XX:TieredStopAtLevel=1
78
+ {%- endif %}
59
79
  Events:
60
80
  Http:
61
81
  Type: HttpApi
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: AWS Lambda for Action Platform: the aws/lambda deploy target (SAM) with its overlay, and tools to read stacks and functions.
5
5
  Author-email: Action Platform <cloud@actionplatform.io>
6
6
  License-Expression: Apache-2.0
@@ -47,7 +47,7 @@ action-platform diagnose
47
47
 
48
48
  | | |
49
49
  |---|---|
50
- | Overlay | `template.yaml`, `samconfig.toml`, `Makefile` and the language's entry point — `lambda_handler.py` (Mangum) for Python, `run.sh` behind the Lambda Web Adapter layer for Node and Spring (Java, Kotlin), `cmd/lambda/main.go` (`-tags lambda`) for Go, `lambda_handler.rb` (a Rack call, no server) for Ruby —, `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional). Every `web/*` template of the official repository deploys; the health route is `/health` (API Gateway keeps `/ping` for itself on `execute-api`) |
50
+ | Overlay | `template.yaml`, `samconfig.toml`, a one-line `Makefile` (`ap-build package`), `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional). One template for every language: the Lambda Web Adapter layer runs the project as an HTTP server on `$PORT` — `run.sh` from `ap-build` (Python `python3.12`, Node `nodejs22.x`, Java/Kotlin `java21`, Ruby `ruby3.3`) or the static `bootstrap` on `provided.al2023` (Go). Every `web/*` template of the official repository deploys; the health route is `/health` (API Gateway keeps `/ping` for itself on `execute-api`) |
51
51
  | Readiness | before a deploy, without building or changing anything: the tooling is there, the overlay is applied, the stack name resolves, the credentials work, the stack is not mid-operation or failed (a `ROLLBACK_COMPLETE` first creation is a warning — the deploy deletes it), the deploy role may do what the template needs (simulated with `iam:SimulatePrincipalPolicy` against the stack, the function, its log group, the execution role and every public layer the template references — the Lambda Web Adapter's, for one) and `sam validate --lint` passes. The platform runs it after every release for `dev` and `prod` and refuses a blocked deploy unless forced; `action-platform readiness` runs it on a machine |
52
52
  | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
53
53
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
@@ -0,0 +1,28 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ apx_aws_lambda/__init__.py
5
+ apx_aws_lambda/cli.py
6
+ apx_aws_lambda/lambda_.py
7
+ apx_aws_lambda/plugin.py
8
+ apx_aws_lambda/proxy.py
9
+ apx_aws_lambda/shell.py
10
+ apx_aws_lambda/tools.py
11
+ apx_aws_lambda.egg-info/PKG-INFO
12
+ apx_aws_lambda.egg-info/SOURCES.txt
13
+ apx_aws_lambda.egg-info/dependency_links.txt
14
+ apx_aws_lambda.egg-info/entry_points.txt
15
+ apx_aws_lambda.egg-info/requires.txt
16
+ apx_aws_lambda.egg-info/top_level.txt
17
+ apx_aws_lambda/overlays/index.json
18
+ apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json
19
+ apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py
20
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md
21
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/Makefile
22
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml
23
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml
24
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml
25
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json
26
+ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json
27
+ tests/test_proxy.py
28
+ tests/test_targets.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "apx-aws-lambda"
3
- version = "0.4.0"
3
+ version = "0.5.0"
4
4
  description = "AWS Lambda for Action Platform: the aws/lambda deploy target (SAM) with its overlay, and tools to read stacks and functions."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -267,7 +267,7 @@ class ProxyClientTest(ProxyCase):
267
267
  deploy[-2:],
268
268
  [
269
269
  "--parameter-overrides",
270
- "ExecutionRoleArn=arn:aws:iam::1:role/action-platform/ap-exec-acme-shop-orders",
270
+ "Stage=dev ExecutionRoleArn=arn:aws:iam::1:role/action-platform/ap-exec-acme-shop-orders",
271
271
  ],
272
272
  )
273
273
 
@@ -84,6 +84,8 @@ class LambdaTargetTest(unittest.TestCase):
84
84
  "shop-prod",
85
85
  "--config-env",
86
86
  "prod",
87
+ "--parameter-overrides",
88
+ "Stage=prod",
87
89
  ],
88
90
  self.calls,
89
91
  )
@@ -1,30 +0,0 @@
1
- """Cloud overlay post-gen: keep files for this language/type, and the selected CI.
2
-
3
- `_lang/<language>/` files that depend on the language (Dockerfile, lambda handler)
4
- """
5
-
6
- import shutil
7
- from pathlib import Path
8
-
9
- LANGUAGE = "{{ cookiecutter.language }}"
10
- CI = "{{ cookiecutter.ci }}"
11
-
12
-
13
- def promote(root: Path, key: str) -> None:
14
- if not root.exists():
15
- return
16
- chosen = root / key
17
- if not chosen.exists():
18
- raise SystemExit(f"cloud overlay has no files under {root.name}/{key}")
19
- for item in chosen.rglob("*"):
20
- if item.is_file():
21
- dest = Path(*item.relative_to(chosen).parts)
22
- dest.parent.mkdir(parents=True, exist_ok=True)
23
- shutil.copy2(item, dest)
24
- shutil.rmtree(root)
25
-
26
-
27
- promote(Path("_lang"), LANGUAGE)
28
-
29
- if CI != "github" and Path(".github").exists():
30
- shutil.rmtree(".github")
@@ -1,6 +0,0 @@
1
- # SAM build recipe (BuildMethod: makefile): one static binary named bootstrap for provided.al2023 on arm64.
2
- # The Lambda modules are fetched at build time, so go.mod stays as the project template left it.
3
-
4
- build-ApiFunction:
5
- go get github.com/aws/aws-lambda-go@latest github.com/awslabs/aws-lambda-go-api-proxy@latest
6
- GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags lambda -ldflags="-s -w" -o "$(ARTIFACTS_DIR)/bootstrap" ./cmd/lambda
@@ -1,25 +0,0 @@
1
- //go:build lambda
2
-
3
- // Lambda entry point: the gin engine from internal/app behind the API Gateway proxy.
4
- // Built with `-tags lambda` only (see Makefile), so `go build ./...` and `go vet` never need the Lambda modules.
5
- package main
6
-
7
- import (
8
- "context"
9
-
10
- "github.com/aws/aws-lambda-go/events"
11
- "github.com/aws/aws-lambda-go/lambda"
12
- ginadapter "github.com/awslabs/aws-lambda-go-api-proxy/gin"
13
-
14
- "github.com/{{ cookiecutter.github_owner }}/{{ cookiecutter.project_slug }}/internal/app"
15
- )
16
-
17
- var adapter = ginadapter.NewV2(app.New())
18
-
19
- func handler(ctx context.Context, req events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) {
20
- return adapter.ProxyWithContext(ctx, req)
21
- }
22
-
23
- func main() {
24
- lambda.Start(handler)
25
- }
@@ -1,97 +0,0 @@
1
- AWSTemplateFormatVersion: '2010-09-09'
2
- Transform: AWS::Serverless-2016-10-31
3
- Description: {{ cookiecutter.project_slug }} — Go app on Lambda behind an HTTP API
4
-
5
- Parameters:
6
- Stage:
7
- Type: String
8
- AllowedValues: [dev, prod]
9
- Default: dev
10
- DomainName:
11
- Type: String
12
- Default: ''
13
- Description: Custom domain (api.example.com). Empty skips it.
14
- DomainCertificateArn:
15
- Type: String
16
- Default: ''
17
- Description: ACM certificate ARN for DomainName, same region. Empty skips the custom domain.
18
- ExecutionRoleArn:
19
- Type: String
20
- Default: ''
21
- Description: An existing execution role (the deploy proxy creates one per app). Empty lets SAM create it.
22
-
23
- Conditions:
24
- IsProd: !Equals [!Ref Stage, prod]
25
- HasExecutionRole: !Not [!Equals [!Ref ExecutionRoleArn, '']]
26
- HasCustomDomain: !Not [!Equals [!Ref DomainCertificateArn, '']]
27
-
28
- Globals:
29
- Function:
30
- Timeout: 30
31
- MemorySize: 512
32
- Architectures: [arm64]
33
-
34
- Resources:
35
- ApiFunction:
36
- Type: AWS::Serverless::Function
37
- Metadata:
38
- BuildMethod: makefile
39
- cfn-lint:
40
- config:
41
- ignore_checks: [E3031]
42
- Properties:
43
- FunctionName: !Sub "${AWS::StackName}-api"
44
- CodeUri: .
45
- Handler: bootstrap
46
- Runtime: provided.al2023
47
- Role: !If [HasExecutionRole, !Ref ExecutionRoleArn, !Ref AWS::NoValue]
48
- Environment:
49
- Variables:
50
- SCOPE: !If [IsProd, production, development]
51
- Events:
52
- Http:
53
- Type: HttpApi
54
- Properties:
55
- ApiId: !Ref HttpApi
56
- Path: /{proxy+}
57
- Method: ANY
58
-
59
- ApiLogGroup:
60
- Type: AWS::Logs::LogGroup
61
- Properties:
62
- LogGroupName: !Sub "/aws/lambda/${AWS::StackName}-api"
63
- RetentionInDays: !If [IsProd, 90, 14]
64
-
65
- HttpApi:
66
- Type: AWS::Serverless::HttpApi
67
- Properties:
68
- StageName: $default
69
- RouteSettings:
70
- "$default":
71
- ThrottlingRateLimit: 100
72
- ThrottlingBurstLimit: 200
73
-
74
- ApiDomainName:
75
- Type: AWS::ApiGatewayV2::DomainName
76
- Condition: HasCustomDomain
77
- Properties:
78
- DomainName: !Ref DomainName
79
- DomainNameConfigurations:
80
- - CertificateArn: !Ref DomainCertificateArn
81
- EndpointType: REGIONAL
82
-
83
- ApiDomainMapping:
84
- Type: AWS::ApiGatewayV2::ApiMapping
85
- Condition: HasCustomDomain
86
- Properties:
87
- ApiId: !Ref HttpApi
88
- DomainName: !Ref ApiDomainName
89
- Stage: !Ref HttpApi.Stage
90
-
91
- Outputs:
92
- ApiUrl:
93
- Value: !Sub "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com"
94
- CustomDomainTarget:
95
- Condition: HasCustomDomain
96
- Description: Point the DNS record for DomainName at this regional target
97
- Value: !GetAtt ApiDomainName.RegionalDomainName
@@ -1,7 +0,0 @@
1
- # SAM build recipe (BuildMethod: makefile): the Spring Boot jar and run.sh — the Lambda Web Adapter layer starts run.sh and proxies HTTP to port 8080.
2
-
3
- build-ApiFunction:
4
- mvn -q -B -DskipTests package
5
- cp target/*.jar "$(ARTIFACTS_DIR)/app.jar"
6
- cp run.sh "$(ARTIFACTS_DIR)/run.sh"
7
- chmod +x "$(ARTIFACTS_DIR)/run.sh"
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- exec java -jar app.jar --server.port=8080
@@ -1,7 +0,0 @@
1
- # SAM build recipe (BuildMethod: makefile): the Spring Boot jar and run.sh — the Lambda Web Adapter layer starts run.sh and proxies HTTP to port 8080.
2
-
3
- build-ApiFunction:
4
- mvn -q -B -DskipTests package
5
- cp target/*.jar "$(ARTIFACTS_DIR)/app.jar"
6
- cp run.sh "$(ARTIFACTS_DIR)/run.sh"
7
- chmod +x "$(ARTIFACTS_DIR)/run.sh"
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- exec java -jar app.jar --server.port=8080
@@ -1,105 +0,0 @@
1
- AWSTemplateFormatVersion: '2010-09-09'
2
- Transform: AWS::Serverless-2016-10-31
3
- Description: {{ cookiecutter.project_slug }} — Spring Boot app on Lambda (Lambda Web Adapter) behind an HTTP API
4
-
5
- Parameters:
6
- Stage:
7
- Type: String
8
- AllowedValues: [dev, prod]
9
- Default: dev
10
- DomainName:
11
- Type: String
12
- Default: ''
13
- Description: Custom domain (api.example.com). Empty skips it.
14
- DomainCertificateArn:
15
- Type: String
16
- Default: ''
17
- Description: ACM certificate ARN for DomainName, same region. Empty skips the custom domain.
18
- ExecutionRoleArn:
19
- Type: String
20
- Default: ''
21
- Description: An existing execution role (the deploy proxy creates one per app). Empty lets SAM create it.
22
-
23
- Conditions:
24
- IsProd: !Equals [!Ref Stage, prod]
25
- HasExecutionRole: !Not [!Equals [!Ref ExecutionRoleArn, '']]
26
- HasCustomDomain: !Not [!Equals [!Ref DomainCertificateArn, '']]
27
-
28
- Globals:
29
- Function:
30
- Timeout: 30
31
- MemorySize: 1024
32
- Architectures: [arm64]
33
-
34
- Resources:
35
- ApiFunction:
36
- Type: AWS::Serverless::Function
37
- Metadata:
38
- BuildMethod: makefile
39
- cfn-lint:
40
- config:
41
- ignore_checks: [E3031]
42
- Properties:
43
- FunctionName: !Sub "${AWS::StackName}-api"
44
- CodeUri: .
45
- Handler: run.sh
46
- Runtime: java17
47
- Role: !If [HasExecutionRole, !Ref ExecutionRoleArn, !Ref AWS::NoValue]
48
- Layers:
49
- - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:25
50
- Environment:
51
- Variables:
52
- SCOPE: !If [IsProd, production, development]
53
- AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap
54
- AWS_LWA_PORT: "8080"
55
- PORT: "8080"
56
- AWS_LWA_READINESS_CHECK_PATH: /health
57
- AWS_LWA_ASYNC_INIT: "true"
58
- JAVA_TOOL_OPTIONS: -XX:+TieredCompilation -XX:TieredStopAtLevel=1
59
- Events:
60
- Http:
61
- Type: HttpApi
62
- Properties:
63
- ApiId: !Ref HttpApi
64
- Path: /{proxy+}
65
- Method: ANY
66
-
67
- ApiLogGroup:
68
- Type: AWS::Logs::LogGroup
69
- Properties:
70
- LogGroupName: !Sub "/aws/lambda/${AWS::StackName}-api"
71
- RetentionInDays: !If [IsProd, 90, 14]
72
-
73
- HttpApi:
74
- Type: AWS::Serverless::HttpApi
75
- Properties:
76
- StageName: $default
77
- RouteSettings:
78
- "$default":
79
- ThrottlingRateLimit: 100
80
- ThrottlingBurstLimit: 200
81
-
82
- ApiDomainName:
83
- Type: AWS::ApiGatewayV2::DomainName
84
- Condition: HasCustomDomain
85
- Properties:
86
- DomainName: !Ref DomainName
87
- DomainNameConfigurations:
88
- - CertificateArn: !Ref DomainCertificateArn
89
- EndpointType: REGIONAL
90
-
91
- ApiDomainMapping:
92
- Type: AWS::ApiGatewayV2::ApiMapping
93
- Condition: HasCustomDomain
94
- Properties:
95
- ApiId: !Ref HttpApi
96
- DomainName: !Ref ApiDomainName
97
- Stage: !Ref HttpApi.Stage
98
-
99
- Outputs:
100
- ApiUrl:
101
- Value: !Sub "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com"
102
- CustomDomainTarget:
103
- Condition: HasCustomDomain
104
- Description: Point the DNS record for DomainName at this regional target
105
- Value: !GetAtt ApiDomainName.RegionalDomainName
@@ -1,11 +0,0 @@
1
- # SAM build recipe (BuildMethod: makefile): the compiled app, its production dependencies and run.sh — the Lambda Web Adapter layer starts run.sh and proxies HTTP to port 8080.
2
-
3
- build-ApiFunction:
4
- [ -f package-lock.json ] && npm ci --no-audit --no-fund || npm install --no-audit --no-fund
5
- npm run build
6
- npm prune --omit=dev --no-audit --no-fund
7
- cp -r dist "$(ARTIFACTS_DIR)/dist"
8
- cp -r node_modules "$(ARTIFACTS_DIR)/node_modules"
9
- cp package.json "$(ARTIFACTS_DIR)/package.json"
10
- cp run.sh "$(ARTIFACTS_DIR)/run.sh"
11
- chmod +x "$(ARTIFACTS_DIR)/run.sh"
@@ -1,102 +0,0 @@
1
- AWSTemplateFormatVersion: '2010-09-09'
2
- Transform: AWS::Serverless-2016-10-31
3
- Description: {{ cookiecutter.project_slug }} — Node app on Lambda (Lambda Web Adapter) behind an HTTP API
4
-
5
- Parameters:
6
- Stage:
7
- Type: String
8
- AllowedValues: [dev, prod]
9
- Default: dev
10
- DomainName:
11
- Type: String
12
- Default: ''
13
- Description: Custom domain (api.example.com). Empty skips it.
14
- DomainCertificateArn:
15
- Type: String
16
- Default: ''
17
- Description: ACM certificate ARN for DomainName, same region. Empty skips the custom domain.
18
- ExecutionRoleArn:
19
- Type: String
20
- Default: ''
21
- Description: An existing execution role (the deploy proxy creates one per app). Empty lets SAM create it.
22
-
23
- Conditions:
24
- IsProd: !Equals [!Ref Stage, prod]
25
- HasExecutionRole: !Not [!Equals [!Ref ExecutionRoleArn, '']]
26
- HasCustomDomain: !Not [!Equals [!Ref DomainCertificateArn, '']]
27
-
28
- Globals:
29
- Function:
30
- Timeout: 30
31
- MemorySize: 512
32
- Architectures: [arm64]
33
-
34
- Resources:
35
- ApiFunction:
36
- Type: AWS::Serverless::Function
37
- Metadata:
38
- BuildMethod: makefile
39
- cfn-lint:
40
- config:
41
- ignore_checks: [E3031]
42
- Properties:
43
- FunctionName: !Sub "${AWS::StackName}-api"
44
- CodeUri: .
45
- Handler: run.sh
46
- Runtime: nodejs22.x
47
- Role: !If [HasExecutionRole, !Ref ExecutionRoleArn, !Ref AWS::NoValue]
48
- Layers:
49
- - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:25
50
- Environment:
51
- Variables:
52
- SCOPE: !If [IsProd, production, development]
53
- AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap
54
- AWS_LWA_PORT: "8080"
55
- PORT: "8080"
56
- Events:
57
- Http:
58
- Type: HttpApi
59
- Properties:
60
- ApiId: !Ref HttpApi
61
- Path: /{proxy+}
62
- Method: ANY
63
-
64
- ApiLogGroup:
65
- Type: AWS::Logs::LogGroup
66
- Properties:
67
- LogGroupName: !Sub "/aws/lambda/${AWS::StackName}-api"
68
- RetentionInDays: !If [IsProd, 90, 14]
69
-
70
- HttpApi:
71
- Type: AWS::Serverless::HttpApi
72
- Properties:
73
- StageName: $default
74
- RouteSettings:
75
- "$default":
76
- ThrottlingRateLimit: 100
77
- ThrottlingBurstLimit: 200
78
-
79
- ApiDomainName:
80
- Type: AWS::ApiGatewayV2::DomainName
81
- Condition: HasCustomDomain
82
- Properties:
83
- DomainName: !Ref DomainName
84
- DomainNameConfigurations:
85
- - CertificateArn: !Ref DomainCertificateArn
86
- EndpointType: REGIONAL
87
-
88
- ApiDomainMapping:
89
- Type: AWS::ApiGatewayV2::ApiMapping
90
- Condition: HasCustomDomain
91
- Properties:
92
- ApiId: !Ref HttpApi
93
- DomainName: !Ref ApiDomainName
94
- Stage: !Ref HttpApi.Stage
95
-
96
- Outputs:
97
- ApiUrl:
98
- Value: !Sub "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com"
99
- CustomDomainTarget:
100
- Condition: HasCustomDomain
101
- Description: Point the DNS record for DomainName at this regional target
102
- Value: !GetAtt ApiDomainName.RegionalDomainName
@@ -1,21 +0,0 @@
1
- # SAM build recipes (BuildMethod: makefile). Deps go to a layer, code to the function.
2
- # The layer is built for the function's platform (arm64, python3.12) from wheels only,
3
- # so the build host — a laptop, CI, the platform's worker — does not matter.
4
-
5
- LAYER_PLATFORM ?= manylinux2014_aarch64
6
- LAYER_PYTHON ?= 3.12
7
-
8
- build-ApiFunction:
9
- cp -r app "$(ARTIFACTS_DIR)/app"
10
- [ -d tools ] && cp -r tools "$(ARTIFACTS_DIR)/tools" || true
11
- cp lambda_handler.py "$(ARTIFACTS_DIR)/lambda_handler.py"
12
-
13
- build-DepsLayer:
14
- mkdir -p "$(ARTIFACTS_DIR)/python"
15
- python -m pip install --quiet --upgrade pip >/dev/null
16
- python tools/lambda_requirements.py "$(ARTIFACTS_DIR)/requirements.txt"
17
- python -m pip install --quiet --target "$(ARTIFACTS_DIR)/python" \
18
- --platform "$(LAYER_PLATFORM)" --python-version "$(LAYER_PYTHON)" \
19
- --implementation cp --only-binary=:all: \
20
- mangum -r "$(ARTIFACTS_DIR)/requirements.txt"
21
- rm -f "$(ARTIFACTS_DIR)/requirements.txt"
@@ -1,21 +0,0 @@
1
- """AWS Lambda entry point — adapts the ASGI app from `app.create_app()` with Mangum.
2
-
3
- The app is rebuilt per invocation with the lifespan run each time: an MCP
4
- session manager refuses to start twice on one instance, and the rebuild costs
5
- milliseconds. Stateless transports are the app's own concern (see create_app).
6
- """
7
-
8
- import os
9
-
10
- from mangum import Mangum
11
-
12
- from app import create_app
13
-
14
-
15
- def lambda_handler(event, context):
16
- adapter = Mangum(
17
- create_app(),
18
- lifespan="auto",
19
- api_gateway_base_path=os.environ.get("API_STAGE") or "/",
20
- )
21
- return adapter(event, context)
@@ -1,110 +0,0 @@
1
- AWSTemplateFormatVersion: '2010-09-09'
2
- Transform: AWS::Serverless-2016-10-31
3
- Description: {{ cookiecutter.project_slug }} — ASGI app on Lambda behind an HTTP API
4
-
5
- Parameters:
6
- Stage:
7
- Type: String
8
- AllowedValues: [dev, prod]
9
- Default: dev
10
- DomainName:
11
- Type: String
12
- Default: ''
13
- Description: Custom domain (api.example.com). Empty skips it.
14
- DomainCertificateArn:
15
- Type: String
16
- Default: ''
17
- Description: ACM certificate ARN for DomainName, same region. Empty skips the custom domain.
18
- ExecutionRoleArn:
19
- Type: String
20
- Default: ''
21
- Description: An existing execution role (the deploy proxy creates one per app). Empty lets SAM create it.
22
-
23
- Conditions:
24
- IsProd: !Equals [!Ref Stage, prod]
25
- HasExecutionRole: !Not [!Equals [!Ref ExecutionRoleArn, '']]
26
- HasCustomDomain: !Not [!Equals [!Ref DomainCertificateArn, '']]
27
-
28
- Globals:
29
- Function:
30
- Timeout: 30
31
- MemorySize: 512
32
- Architectures: [arm64]
33
-
34
- Resources:
35
- DepsLayer:
36
- Type: AWS::Serverless::LayerVersion
37
- Metadata:
38
- BuildMethod: makefile
39
- Properties:
40
- LayerName: !Sub "${AWS::StackName}-deps"
41
- ContentUri: .
42
- CompatibleRuntimes: [python3.12]
43
- CompatibleArchitectures: [arm64]
44
- RetentionPolicy: Delete
45
-
46
- ApiFunction:
47
- Type: AWS::Serverless::Function
48
- Metadata:
49
- BuildMethod: makefile
50
- cfn-lint:
51
- config:
52
- ignore_checks: [E3031]
53
- Properties:
54
- FunctionName: !Sub "${AWS::StackName}-api"
55
- CodeUri: .
56
- Handler: lambda_handler.lambda_handler
57
- Runtime: python3.12
58
- Role: !If [HasExecutionRole, !Ref ExecutionRoleArn, !Ref AWS::NoValue]
59
- Layers: [!Ref DepsLayer]
60
- Environment:
61
- Variables:
62
- SCOPE: !If [IsProd, production, development]
63
- API_STAGE: ""
64
- Events:
65
- Http:
66
- Type: HttpApi
67
- Properties:
68
- ApiId: !Ref HttpApi
69
- Path: /{proxy+}
70
- Method: ANY
71
-
72
- ApiLogGroup:
73
- Type: AWS::Logs::LogGroup
74
- Properties:
75
- LogGroupName: !Sub "/aws/lambda/${AWS::StackName}-api"
76
- RetentionInDays: !If [IsProd, 90, 14]
77
-
78
- HttpApi:
79
- Type: AWS::Serverless::HttpApi
80
- Properties:
81
- StageName: $default
82
- RouteSettings:
83
- "$default":
84
- ThrottlingRateLimit: 100
85
- ThrottlingBurstLimit: 200
86
-
87
- ApiDomainName:
88
- Type: AWS::ApiGatewayV2::DomainName
89
- Condition: HasCustomDomain
90
- Properties:
91
- DomainName: !Ref DomainName
92
- DomainNameConfigurations:
93
- - CertificateArn: !Ref DomainCertificateArn
94
- EndpointType: REGIONAL
95
-
96
- ApiDomainMapping:
97
- Type: AWS::ApiGatewayV2::ApiMapping
98
- Condition: HasCustomDomain
99
- Properties:
100
- ApiId: !Ref HttpApi
101
- DomainName: !Ref ApiDomainName
102
- Stage: !Ref HttpApi.Stage
103
-
104
- Outputs:
105
- ApiUrl:
106
- Value: !Sub "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com"
107
- CustomDomainTarget:
108
- Condition: HasCustomDomain
109
- Description: Point the DNS record for DomainName at this regional target
110
- Value: !GetAtt ApiDomainName.RegionalDomainName
@@ -1,93 +0,0 @@
1
- """Requirements for the Lambda layer without poetry on the build host: pins from poetry.lock when it exists, otherwise the main dependencies of pyproject.toml (PEP 621 or poetry's caret/tilde constraints turned into PEP 440)."""
2
-
3
- import re
4
- import sys
5
- from pathlib import Path
6
-
7
- import tomllib
8
-
9
-
10
- def caret(version: str) -> str:
11
- parts = [int(p) for p in re.findall(r"\d+", version)]
12
- upper = list(parts)
13
-
14
- for i, p in enumerate(parts):
15
- if p != 0 or i == len(parts) - 1:
16
- upper = parts[:i] + [p + 1] + [0] * (len(parts) - i - 1)
17
- break
18
-
19
- return f">={version},<{'.'.join(str(p) for p in upper)}"
20
-
21
-
22
- def tilde(version: str) -> str:
23
- parts = [int(p) for p in re.findall(r"\d+", version)]
24
- upper = parts[:1] + [parts[1] + 1] if len(parts) > 1 else [parts[0] + 1]
25
-
26
- return f">={version},<{'.'.join(str(p) for p in upper)}"
27
-
28
-
29
- def constraint(spec: str) -> str:
30
- spec = spec.strip()
31
-
32
- if spec in ("*", ""):
33
- return ""
34
-
35
- if spec.startswith("^"):
36
- return caret(spec[1:])
37
-
38
- if spec.startswith("~") and not spec.startswith("~="):
39
- return tilde(spec[1:])
40
-
41
- if re.match(r"^\d", spec):
42
- return f"=={spec}"
43
-
44
- return spec
45
-
46
-
47
- def from_poetry(deps: dict) -> list[str]:
48
- rows = []
49
-
50
- for name, spec in deps.items():
51
- if name.lower() == "python":
52
- continue
53
-
54
- extras = ""
55
- version = spec
56
-
57
- if isinstance(spec, dict):
58
- if spec.get("optional"):
59
- continue
60
-
61
- version = spec.get("version", "*")
62
- extras = (
63
- f"[{','.join(spec['extras'])}]" if spec.get("extras") else ""
64
- )
65
-
66
- rows.append(f"{name}{extras}{constraint(str(version))}")
67
-
68
- return rows
69
-
70
-
71
- def main(out: str) -> None:
72
- lock = Path("poetry.lock")
73
-
74
- if lock.exists():
75
- data = tomllib.loads(lock.read_text())
76
- rows = [
77
- f"{p['name']}=={p['version']}"
78
- for p in data.get("package", [])
79
- if "main" in (p.get("groups") or ["main"])
80
- ]
81
- else:
82
- pyproject = tomllib.loads(Path("pyproject.toml").read_text())
83
- rows = list(pyproject.get("project", {}).get("dependencies") or [])
84
- rows += from_poetry(
85
- pyproject.get("tool", {}).get("poetry", {}).get("dependencies")
86
- or {}
87
- )
88
-
89
- Path(out).write_text("\n".join(rows) + "\n")
90
-
91
-
92
- if __name__ == "__main__":
93
- main(sys.argv[1])
@@ -1,19 +0,0 @@
1
- # SAM build recipe (BuildMethod: makefile): the app, its gems and the handler.
2
- # Lambda calls the Rack app directly, so the server gems (puma, rackup — native extensions) stay out:
3
- # a Gemfile without them is resolved for the package, and the build host needs no compiler.
4
- # Bundler is driven by environment only — the project's own .bundle/config is never touched.
5
-
6
- LAMBDA_BUNDLE = BUNDLE_GEMFILE=Gemfile.lambda BUNDLE_PATH=vendor/lambda BUNDLE_WITHOUT=development:test BUNDLE_FROZEN=false
7
-
8
- build-ApiFunction:
9
- grep -v -E '^\s*gem "(puma|rackup)"' Gemfile > Gemfile.lambda
10
- $(LAMBDA_BUNDLE) bundle install --quiet
11
- cp -r app "$(ARTIFACTS_DIR)/app"
12
- cp app.rb config.ru lambda_handler.rb "$(ARTIFACTS_DIR)/"
13
- cp Gemfile.lambda "$(ARTIFACTS_DIR)/Gemfile"
14
- cp Gemfile.lambda.lock "$(ARTIFACTS_DIR)/Gemfile.lock"
15
- mkdir -p "$(ARTIFACTS_DIR)/vendor/bundle" "$(ARTIFACTS_DIR)/.bundle"
16
- cp -r vendor/lambda/. "$(ARTIFACTS_DIR)/vendor/bundle/"
17
- printf 'BUNDLE_PATH: "vendor/bundle"\nBUNDLE_WITHOUT: "development:test"\n' > "$(ARTIFACTS_DIR)/.bundle/config"
18
- rm -rf vendor/lambda Gemfile.lambda Gemfile.lambda.lock
19
- rmdir vendor 2>/dev/null || true
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Lambda entry point: the Rack app from app.rb, called with the request API Gateway
4
- # (HTTP API, payload v2) delivers. No adapter gem, no server: the event becomes a
5
- # Rack env, the triplet becomes the response.
6
-
7
- require "bundler/setup"
8
-
9
- require "base64"
10
- require "rack"
11
- require "stringio"
12
-
13
- require_relative "app"
14
-
15
- APP = App.create
16
- BODY_HEADERS = %w[content-type content-length].freeze
17
-
18
- def handler(event:, context:)
19
- status, headers, body = APP.call(rack_env(event, context))
20
- chunks = body.map(&:to_s)
21
- body.close if body.respond_to?(:close)
22
-
23
- {
24
- "statusCode" => status,
25
- "headers" => headers.to_h.transform_values(&:to_s),
26
- "body" => chunks.join,
27
- "isBase64Encoded" => false
28
- }
29
- end
30
-
31
- def rack_env(event, context)
32
- headers = (event["headers"] || {}).transform_keys { |k| k.to_s.downcase }
33
- env = base_env(event, headers, context)
34
- headers.each { |name, value| env[header_key(name)] = value }
35
- env
36
- end
37
-
38
- RACK_STATIC = {
39
- "SCRIPT_NAME" => "",
40
- "SERVER_PORT" => "443",
41
- "SERVER_PROTOCOL" => "HTTP/1.1",
42
- "rack.version" => Rack::VERSION,
43
- "rack.url_scheme" => "https",
44
- "rack.errors" => $stderr,
45
- "rack.multithread" => false,
46
- "rack.multiprocess" => false,
47
- "rack.run_once" => false
48
- }.freeze
49
-
50
- def base_env(event, headers, context)
51
- RACK_STATIC.merge(
52
- "REQUEST_METHOD" => event.fetch("requestContext").fetch("http")["method"],
53
- "PATH_INFO" => event["rawPath"] || "/",
54
- "QUERY_STRING" => event["rawQueryString"].to_s,
55
- "SERVER_NAME" => headers["host"] || "localhost",
56
- "rack.input" => StringIO.new(request_body(event)),
57
- "lambda.event" => event,
58
- "lambda.context" => context
59
- )
60
- end
61
-
62
- def request_body(event)
63
- body = event["body"].to_s
64
- event["isBase64Encoded"] ? Base64.decode64(body) : body
65
- end
66
-
67
- def header_key(name)
68
- key = name.upcase.tr("-", "_")
69
- BODY_HEADERS.include?(name) ? key : "HTTP_#{key}"
70
- end
@@ -1,99 +0,0 @@
1
- AWSTemplateFormatVersion: '2010-09-09'
2
- Transform: AWS::Serverless-2016-10-31
3
- Description: {{ cookiecutter.project_slug }} — Rack app on Lambda behind an HTTP API
4
-
5
- Parameters:
6
- Stage:
7
- Type: String
8
- AllowedValues: [dev, prod]
9
- Default: dev
10
- DomainName:
11
- Type: String
12
- Default: ''
13
- Description: Custom domain (api.example.com). Empty skips it.
14
- DomainCertificateArn:
15
- Type: String
16
- Default: ''
17
- Description: ACM certificate ARN for DomainName, same region. Empty skips the custom domain.
18
- ExecutionRoleArn:
19
- Type: String
20
- Default: ''
21
- Description: An existing execution role (the deploy proxy creates one per app). Empty lets SAM create it.
22
-
23
- Conditions:
24
- IsProd: !Equals [!Ref Stage, prod]
25
- HasExecutionRole: !Not [!Equals [!Ref ExecutionRoleArn, '']]
26
- HasCustomDomain: !Not [!Equals [!Ref DomainCertificateArn, '']]
27
-
28
- Globals:
29
- Function:
30
- Timeout: 30
31
- MemorySize: 512
32
- Architectures: [arm64]
33
-
34
- Resources:
35
- ApiFunction:
36
- Type: AWS::Serverless::Function
37
- Metadata:
38
- BuildMethod: makefile
39
- cfn-lint:
40
- config:
41
- ignore_checks: [E3031]
42
- Properties:
43
- FunctionName: !Sub "${AWS::StackName}-api"
44
- CodeUri: .
45
- Handler: lambda_handler.handler
46
- Runtime: ruby3.3
47
- Role: !If [HasExecutionRole, !Ref ExecutionRoleArn, !Ref AWS::NoValue]
48
- Environment:
49
- Variables:
50
- SCOPE: !If [IsProd, production, development]
51
- APP_ENV: production
52
- RACK_ENV: production
53
- Events:
54
- Http:
55
- Type: HttpApi
56
- Properties:
57
- ApiId: !Ref HttpApi
58
- Path: /{proxy+}
59
- Method: ANY
60
-
61
- ApiLogGroup:
62
- Type: AWS::Logs::LogGroup
63
- Properties:
64
- LogGroupName: !Sub "/aws/lambda/${AWS::StackName}-api"
65
- RetentionInDays: !If [IsProd, 90, 14]
66
-
67
- HttpApi:
68
- Type: AWS::Serverless::HttpApi
69
- Properties:
70
- StageName: $default
71
- RouteSettings:
72
- "$default":
73
- ThrottlingRateLimit: 100
74
- ThrottlingBurstLimit: 200
75
-
76
- ApiDomainName:
77
- Type: AWS::ApiGatewayV2::DomainName
78
- Condition: HasCustomDomain
79
- Properties:
80
- DomainName: !Ref DomainName
81
- DomainNameConfigurations:
82
- - CertificateArn: !Ref DomainCertificateArn
83
- EndpointType: REGIONAL
84
-
85
- ApiDomainMapping:
86
- Type: AWS::ApiGatewayV2::ApiMapping
87
- Condition: HasCustomDomain
88
- Properties:
89
- ApiId: !Ref HttpApi
90
- DomainName: !Ref ApiDomainName
91
- Stage: !Ref HttpApi.Stage
92
-
93
- Outputs:
94
- ApiUrl:
95
- Value: !Sub "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com"
96
- CustomDomainTarget:
97
- Condition: HasCustomDomain
98
- Description: Point the DNS record for DomainName at this regional target
99
- Value: !GetAtt ApiDomainName.RegionalDomainName
@@ -1,45 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- apx_aws_lambda/__init__.py
5
- apx_aws_lambda/cli.py
6
- apx_aws_lambda/lambda_.py
7
- apx_aws_lambda/plugin.py
8
- apx_aws_lambda/proxy.py
9
- apx_aws_lambda/shell.py
10
- apx_aws_lambda/tools.py
11
- apx_aws_lambda.egg-info/PKG-INFO
12
- apx_aws_lambda.egg-info/SOURCES.txt
13
- apx_aws_lambda.egg-info/dependency_links.txt
14
- apx_aws_lambda.egg-info/entry_points.txt
15
- apx_aws_lambda.egg-info/requires.txt
16
- apx_aws_lambda.egg-info/top_level.txt
17
- apx_aws_lambda/overlays/index.json
18
- apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json
19
- apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py
20
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md
21
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml
22
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml
23
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/Makefile
24
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/template.yaml
25
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/cmd/lambda/main.go
26
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/Makefile
27
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/run.sh
28
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/template.yaml
29
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/Makefile
30
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/run.sh
31
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/template.yaml
32
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/Makefile
33
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/run.sh
34
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/template.yaml
35
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile
36
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py
37
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/template.yaml
38
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py
39
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/Makefile
40
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/lambda_handler.rb
41
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/template.yaml
42
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json
43
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json
44
- tests/test_proxy.py
45
- tests/test_targets.py
File without changes
File without changes