apx-aws-lambda 0.3.6__tar.gz → 0.3.8__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 (49) hide show
  1. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/PKG-INFO +3 -3
  2. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/README.md +2 -2
  3. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/lambda_.py +34 -7
  4. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +6 -1
  5. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +6 -1
  6. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +50 -0
  7. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/Makefile +6 -0
  8. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/cmd/lambda/main.go +25 -0
  9. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/template.yaml +97 -0
  10. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/Makefile +7 -0
  11. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/run.sh +2 -0
  12. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/template.yaml +105 -0
  13. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/Makefile +7 -0
  14. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/run.sh +2 -0
  15. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/template.yaml +105 -0
  16. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/Makefile +11 -0
  17. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/run.sh +2 -0
  18. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/template.yaml +102 -0
  19. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/Makefile +11 -0
  20. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/lambda_handler.rb +54 -0
  21. apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/template.yaml +99 -0
  22. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/index.json +6 -1
  23. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/proxy.py +2 -2
  24. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda.egg-info/PKG-INFO +3 -3
  25. apx_aws_lambda-0.3.8/apx_aws_lambda.egg-info/SOURCES.txt +45 -0
  26. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/pyproject.toml +1 -1
  27. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/tests/test_proxy.py +93 -1
  28. apx_aws_lambda-0.3.6/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -40
  29. apx_aws_lambda-0.3.6/apx_aws_lambda.egg-info/SOURCES.txt +0 -30
  30. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/LICENSE +0 -0
  31. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/__init__.py +0 -0
  32. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/cli.py +0 -0
  33. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
  34. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -0
  35. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
  36. {apx_aws_lambda-0.3.6/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}} → apx_aws_lambda-0.3.8/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python}/template.yaml +0 -0
  37. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -0
  38. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
  39. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
  40. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
  41. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/plugin.py +0 -0
  42. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/shell.py +0 -0
  43. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda/tools.py +0 -0
  44. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
  45. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
  46. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda.egg-info/requires.txt +0 -0
  47. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/apx_aws_lambda.egg-info/top_level.txt +0 -0
  48. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/setup.cfg +0 -0
  49. {apx_aws_lambda-0.3.6 → apx_aws_lambda-0.3.8}/tests/test_targets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.6
3
+ Version: 0.3.8
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,11 +47,11 @@ action-platform diagnose
47
47
 
48
48
  | | |
49
49
  |---|---|
50
- | Overlay | `template.yaml`, `samconfig.toml`, `lambda_handler.py`, `Makefile`, `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional) |
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`) |
51
51
  | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`) |
52
52
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
53
53
  | Diagnose | stack status and the HTTP API url |
54
- | Destroy | `sam delete` |
54
+ | Destroy | `sam delete` of the stage's stack; when no stage is left, the app leaves the proxy too (roles and grant) — the token must carry `org.manage`, which a platform deploy by an organization manager does |
55
55
  | Tools | `aws_lambda_stacks`, `aws_lambda_functions` |
56
56
  | Commands | `action-platform aws-lambda stacks\|functions`, `action-platform aws-lambda proxy …` |
57
57
 
@@ -27,11 +27,11 @@ action-platform diagnose
27
27
 
28
28
  | | |
29
29
  |---|---|
30
- | Overlay | `template.yaml`, `samconfig.toml`, `lambda_handler.py`, `Makefile`, `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional) |
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`) |
31
31
  | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`) |
32
32
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
33
33
  | Diagnose | stack status and the HTTP API url |
34
- | Destroy | `sam delete` |
34
+ | Destroy | `sam delete` of the stage's stack; when no stage is left, the app leaves the proxy too (roles and grant) — the token must carry `org.manage`, which a platform deploy by an organization manager does |
35
35
  | Tools | `aws_lambda_stacks`, `aws_lambda_functions` |
36
36
  | Commands | `action-platform aws-lambda stacks\|functions`, `action-platform aws-lambda proxy …` |
37
37
 
@@ -6,6 +6,7 @@ from __future__ import annotations
6
6
 
7
7
  import os
8
8
  import tomllib
9
+ from dataclasses import replace
9
10
 
10
11
  from action_platform.abc import DeployTarget
11
12
  from action_platform.core.context import Context, DeployResult, Diagnosis
@@ -13,7 +14,7 @@ from action_platform.core.exception import ActionPlatformError, DeployError
13
14
  from action_platform.remote.client import Remote
14
15
 
15
16
  from apx_aws_lambda import shell
16
- from apx_aws_lambda.proxy import ProxyClient
17
+ from apx_aws_lambda.proxy import ProxyClient, ProxyRefused
17
18
 
18
19
 
19
20
  class LambdaTarget(DeployTarget):
@@ -233,14 +234,40 @@ class LambdaTarget(DeployTarget):
233
234
  )
234
235
 
235
236
  def delete(self, ctx: Context) -> None:
236
- sam = shell.require("sam", "pip install aws-sam-cli")
237
- args = [*sam, "delete", "--no-prompts", "--stack-name", self._stack(ctx)]
238
- region = self._region(ctx)
237
+ """The stage's stack goes; once no stage is left, the app leaves the proxy too — its roles and grant — when the token may (`org.manage`)."""
238
+ if self.diagnose(ctx).status != "missing":
239
+ sam = shell.require("sam", "pip install aws-sam-cli")
240
+ args = [*sam, "delete", "--no-prompts", "--stack-name", self._stack(ctx)]
241
+ region = self._region(ctx)
242
+
243
+ if region:
244
+ args += ["--region", region]
245
+
246
+ shell.run(args, cwd=ctx.repo_root, env=self.env(ctx))
247
+
248
+ proxy = self.proxy(ctx)
249
+
250
+ if proxy is None or self._other_stage_lives(ctx):
251
+ return
252
+
253
+ try:
254
+ proxy.delete(token=proxy.token(ctx))
255
+ except ProxyRefused as e:
256
+ if e.status == 404:
257
+ return
258
+
259
+ if e.status == 403:
260
+ raise DeployError(
261
+ f"the stacks are gone but the proxy still knows {proxy.app} ({e.detail}): "
262
+ "delete as an organization manager, or run `action-platform aws-lambda proxy delete`"
263
+ ) from e
264
+
265
+ raise
239
266
 
240
- if region:
241
- args += ["--region", region]
267
+ def _other_stage_lives(self, ctx: Context) -> bool:
268
+ other = replace(ctx, stage="dev" if ctx.stage == "prod" else "prod")
242
269
 
243
- shell.run(args, cwd=ctx.repo_root, env=self.env(ctx))
270
+ return self.diagnose(other).status != "missing"
244
271
 
245
272
  def _url(self, ctx: Context) -> str | None:
246
273
  try:
@@ -4,7 +4,12 @@
4
4
  "github_owner": "actionplatform",
5
5
  "package_name": "{{ cookiecutter.project_slug|replace('-', '_') }}",
6
6
  "language": [
7
- "python"
7
+ "python",
8
+ "node",
9
+ "go",
10
+ "java",
11
+ "kotlin",
12
+ "ruby"
8
13
  ],
9
14
  "type": [
10
15
  "web"
@@ -45,13 +45,18 @@ jobs:
45
45
  role-to-assume: ${{ env.AWS_DEPLOY_ROLE_ARN }}
46
46
  aws-region: us-east-1
47
47
 
48
+ - uses: actionplatform/ci-github/setup@v1
49
+ if: steps.gate.outputs.ready == 'true'
50
+ with:
51
+ install: "false"
52
+
48
53
  - uses: actions/setup-python@v6
49
54
  if: steps.gate.outputs.ready == 'true'
50
55
  with:
51
56
  python-version: "3.12"
52
57
 
53
58
  - if: steps.gate.outputs.ready == 'true'
54
- run: pip install "poetry>=1.8.0" poetry-plugin-export aws-sam-cli
59
+ run: pip install aws-sam-cli
55
60
 
56
61
  - if: steps.gate.outputs.ready == 'true'
57
62
  run: sam build
@@ -0,0 +1,50 @@
1
+ # Deploy — AWS Lambda (SAM)
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:
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 |
12
+
13
+ The route is `/health` — API Gateway reserves `/ping` on `execute-api` and answers it itself.
14
+
15
+ ## Local
16
+
17
+ ```bash
18
+ pip install aws-sam-cli
19
+ sam build
20
+ sam local start-api # http://127.0.0.1:3000/health
21
+ sam deploy # dev stack
22
+ sam deploy --config-env prod # prod stack
23
+ ```
24
+
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.
26
+
27
+ ## CI
28
+
29
+ `.github/workflows/deploy.yml` deploys on push: `develop` → dev, `master`/`main` → prod. Per environment: secret `AWS_DEPLOY_ROLE_ARN` (OIDC role); optional `DOMAIN_NAME` var + `DOMAIN_CERTIFICATE_ARN` secret for a custom domain. The toolchain comes from `actionplatform/ci-github/setup` (reads `platform.toml`).
30
+
31
+ ## Files
32
+
33
+ ```
34
+ template.yaml # SAM resources: function, HTTP API (a deps layer for Python)
35
+ samconfig.toml # dev / prod stacks
36
+ Makefile # SAM build recipes for the language
37
+ run.sh | lambda_handler.* | cmd/lambda/ # how the language's app is started on Lambda
38
+ ```
39
+
40
+ ## Requirements — IAM
41
+
42
+ `requirements/` declares the least privilege the deploy role needs. Create it once per account:
43
+
44
+ ```bash
45
+ sed -i "s/ACCOUNT_ID/$(aws sts get-caller-identity --query Account --output text)/g" requirements/*.json
46
+ aws iam create-role --role-name {{ cookiecutter.project_slug }}-deploy --assume-role-policy-document file://requirements/trust.json
47
+ aws iam put-role-policy --role-name {{ cookiecutter.project_slug }}-deploy --policy-name deploy --policy-document file://requirements/policy.json
48
+ ```
49
+
50
+ `trust.json` trusts GitHub OIDC for this repo only. Put the role ARN in the `AWS_DEPLOY_ROLE_ARN` secret.
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,25 @@
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
+ }
@@ -0,0 +1,97 @@
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
@@ -0,0 +1,7 @@
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"
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ exec java -jar app.jar --server.port=8080
@@ -0,0 +1,105 @@
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
@@ -0,0 +1,7 @@
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"
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ exec java -jar app.jar --server.port=8080
@@ -0,0 +1,105 @@
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
@@ -0,0 +1,11 @@
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"
@@ -0,0 +1,102 @@
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
@@ -0,0 +1,11 @@
1
+ # SAM build recipe (BuildMethod: makefile): the app, its gems (without the development and test groups) and the handler.
2
+ # Only pure-Ruby gems are loaded on Lambda (rack, sinatra); puma stays in the Gemfile for local runs and is never required there.
3
+
4
+ build-ApiFunction:
5
+ bundle config set --local path vendor/bundle
6
+ bundle config set --local without development:test
7
+ bundle install --quiet
8
+ cp -r app "$(ARTIFACTS_DIR)/app"
9
+ cp app.rb config.ru Gemfile Gemfile.lock lambda_handler.rb "$(ARTIFACTS_DIR)/"
10
+ cp -r vendor "$(ARTIFACTS_DIR)/vendor"
11
+ cp -r .bundle "$(ARTIFACTS_DIR)/.bundle"
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Lambda entry point: the Rack app from app.rb called with the request API Gateway (HTTP API, payload v2) delivers.
4
+ # No adapter gem and no server: the event becomes a Rack env, the triplet becomes the response.
5
+
6
+ require "base64"
7
+ require "rack"
8
+ require "stringio"
9
+
10
+ require_relative "app"
11
+
12
+ APP = App.create
13
+
14
+ def handler(event:, context:)
15
+ http = event.fetch("requestContext").fetch("http")
16
+ body = event["body"].to_s
17
+ body = Base64.decode64(body) if event["isBase64Encoded"]
18
+ headers = (event["headers"] || {}).transform_keys { |k| k.to_s.downcase }
19
+
20
+ env = {
21
+ "REQUEST_METHOD" => http["method"],
22
+ "SCRIPT_NAME" => "",
23
+ "PATH_INFO" => event["rawPath"] || "/",
24
+ "QUERY_STRING" => event["rawQueryString"].to_s,
25
+ "SERVER_NAME" => headers["host"] || "localhost",
26
+ "SERVER_PORT" => "443",
27
+ "SERVER_PROTOCOL" => "HTTP/1.1",
28
+ "rack.version" => Rack::VERSION,
29
+ "rack.url_scheme" => "https",
30
+ "rack.input" => StringIO.new(body),
31
+ "rack.errors" => $stderr,
32
+ "rack.multithread" => false,
33
+ "rack.multiprocess" => false,
34
+ "rack.run_once" => false,
35
+ "lambda.event" => event,
36
+ "lambda.context" => context
37
+ }
38
+ headers.each do |name, value|
39
+ key = name.upcase.tr("-", "_")
40
+ env[%w[content-type content-length].include?(name) ? key : "HTTP_#{key}"] = value
41
+ end
42
+
43
+ status, response_headers, response_body = APP.call(env)
44
+ chunks = []
45
+ response_body.each { |chunk| chunks << chunk }
46
+ response_body.close if response_body.respond_to?(:close)
47
+
48
+ {
49
+ "statusCode" => status,
50
+ "headers" => response_headers.to_h.transform_values(&:to_s),
51
+ "body" => chunks.join,
52
+ "isBase64Encoded" => false
53
+ }
54
+ end
@@ -0,0 +1,99 @@
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
@@ -7,7 +7,12 @@
7
7
  "web"
8
8
  ],
9
9
  "languages": [
10
- "python"
10
+ "python",
11
+ "node",
12
+ "go",
13
+ "java",
14
+ "kotlin",
15
+ "ruby"
11
16
  ]
12
17
  }
13
18
  ]
@@ -100,8 +100,8 @@ class ProxyClient:
100
100
  def show(self) -> dict:
101
101
  return self._call("GET", f"/apps/{self.app}", token=self.token())
102
102
 
103
- def delete(self) -> dict:
104
- return self._call("DELETE", f"/apps/{self.app}", token=self.token())
103
+ def delete(self, token: str | None = None) -> dict:
104
+ return self._call("DELETE", f"/apps/{self.app}", token=token or self.token())
105
105
 
106
106
  def grant(self, subjects: list[str]) -> dict:
107
107
  return self._call(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.6
3
+ Version: 0.3.8
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,11 +47,11 @@ action-platform diagnose
47
47
 
48
48
  | | |
49
49
  |---|---|
50
- | Overlay | `template.yaml`, `samconfig.toml`, `lambda_handler.py`, `Makefile`, `requirements/` (IAM examples), `.github/workflows/deploy.yml` (optional) |
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`) |
51
51
  | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`) |
52
52
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
53
53
  | Diagnose | stack status and the HTTP API url |
54
- | Destroy | `sam delete` |
54
+ | Destroy | `sam delete` of the stage's stack; when no stage is left, the app leaves the proxy too (roles and grant) — the token must carry `org.manage`, which a platform deploy by an organization manager does |
55
55
  | Tools | `aws_lambda_stacks`, `aws_lambda_functions` |
56
56
  | Commands | `action-platform aws-lambda stacks\|functions`, `action-platform aws-lambda proxy …` |
57
57
 
@@ -0,0 +1,45 @@
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "apx-aws-lambda"
3
- version = "0.3.6"
3
+ version = "0.3.8"
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"
@@ -58,7 +58,7 @@ class FakeProxy:
58
58
  )
59
59
 
60
60
 
61
- class ProxyClientTest(unittest.TestCase):
61
+ class ProxyCase(unittest.TestCase):
62
62
  def setUp(self):
63
63
  self.tmp = TemporaryDirectory()
64
64
  self.root = Path(self.tmp.name)
@@ -72,6 +72,8 @@ class ProxyClientTest(unittest.TestCase):
72
72
  identity=(lambda audience: f"{token}:{audience}") if token else None,
73
73
  )
74
74
 
75
+
76
+ class ProxyClientTest(ProxyCase):
75
77
  def test_env_carries_credentials_from_the_grant(self):
76
78
  fake = FakeProxy({"POST /apps/acme/shop/orders/credentials": GRANTED})
77
79
 
@@ -268,3 +270,93 @@ class ProxyClientTest(unittest.TestCase):
268
270
  "ExecutionRoleArn=arn:aws:iam::1:role/action-platform/ap-exec-acme-shop-orders",
269
271
  ],
270
272
  )
273
+
274
+
275
+ class DeleteTest(ProxyCase):
276
+ def run_with(self, live: set[str]):
277
+ calls: list[list[str]] = []
278
+
279
+ def run(args, cwd=None, env=None):
280
+ calls.append(args)
281
+
282
+ if args[1:3] == ["cloudformation", "describe-stacks"]:
283
+ stack = args[args.index("--stack-name") + 1]
284
+
285
+ if stack not in live:
286
+ raise DeployError("does not exist")
287
+
288
+ return json.dumps({"Stacks": [{"StackStatus": "UPDATE_COMPLETE"}]})
289
+
290
+ if args[1] == "delete":
291
+ live.discard(args[args.index("--stack-name") + 1])
292
+
293
+ return "{}"
294
+
295
+ return calls, run
296
+
297
+ def test_delete_drops_the_stage_and_leaves_the_proxy_while_another_stage_lives(
298
+ self,
299
+ ):
300
+ (self.root / "samconfig.toml").write_text(SAMCONFIG.format(stack="x"))
301
+ fake = FakeProxy({"POST /apps/acme/shop/orders/credentials": GRANTED})
302
+ target = LambdaTarget(proxy_url="https://proxy.test", app="acme/shop/orders")
303
+ calls, run = self.run_with(
304
+ {"ap-acme-shop-orders-dev", "ap-acme-shop-orders-prod"}
305
+ )
306
+
307
+ with (
308
+ mock.patch("urllib.request.urlopen", fake),
309
+ mock.patch.multiple(
310
+ shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
311
+ ),
312
+ ):
313
+ target.delete(self.ctx())
314
+
315
+ deleted = next(c for c in calls if c[1] == "delete")
316
+ self.assertEqual(
317
+ deleted[deleted.index("--stack-name") + 1], "ap-acme-shop-orders-dev"
318
+ )
319
+ self.assertNotIn("DELETE", [r[0] for r in fake.requests])
320
+
321
+ def test_delete_of_the_last_stage_deregisters_the_app(self):
322
+ (self.root / "samconfig.toml").write_text(SAMCONFIG.format(stack="x"))
323
+ fake = FakeProxy(
324
+ {
325
+ "POST /apps/acme/shop/orders/credentials": GRANTED,
326
+ "DELETE /apps/acme/shop/orders": {"deleted": True},
327
+ }
328
+ )
329
+ target = LambdaTarget(proxy_url="https://proxy.test", app="acme/shop/orders")
330
+ calls, run = self.run_with({"ap-acme-shop-orders-dev"})
331
+
332
+ with (
333
+ mock.patch("urllib.request.urlopen", fake),
334
+ mock.patch.multiple(
335
+ shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
336
+ ),
337
+ ):
338
+ target.delete(self.ctx())
339
+
340
+ self.assertEqual(
341
+ [r[:2] for r in fake.requests if r[0] == "DELETE"],
342
+ [("DELETE", "/apps/acme/shop/orders")],
343
+ )
344
+ self.assertEqual(len([c for c in calls if c[1] == "delete"]), 1)
345
+
346
+ def test_delete_without_org_manage_says_who_can_finish(self):
347
+ (self.root / "samconfig.toml").write_text(SAMCONFIG.format(stack="x"))
348
+ fake = FakeProxy({"POST /apps/acme/shop/orders/credentials": GRANTED})
349
+ target = LambdaTarget(proxy_url="https://proxy.test", app="acme/shop/orders")
350
+ calls, run = self.run_with(set())
351
+
352
+ with (
353
+ mock.patch("urllib.request.urlopen", fake),
354
+ mock.patch.multiple(
355
+ shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
356
+ ),
357
+ ):
358
+ with self.assertRaises(DeployError) as caught:
359
+ target.delete(self.ctx())
360
+
361
+ self.assertIn("organization manager", str(caught.exception))
362
+ self.assertEqual([c for c in calls if c[1] == "delete"], [])
@@ -1,40 +0,0 @@
1
- # Deploy — AWS Lambda (SAM)
2
-
3
- Overlay `cloud/aws/lambda`. The app runs on Lambda (arm64, python3.12) behind an HTTP API Gateway. Dependencies build into a layer; code into the function.
4
-
5
- ## Local
6
-
7
- ```bash
8
- pip install aws-sam-cli
9
- sam build
10
- sam local start-api # http://127.0.0.1:3000/ping
11
- sam deploy # dev stack: {{ cookiecutter.project_slug }}-dev
12
- sam deploy --config-env prod # prod stack: {{ cookiecutter.project_slug }}-prod
13
- ```
14
-
15
- ## CI
16
-
17
- `.github/workflows/deploy.yml` deploys on push: `develop` → dev, `master`/`main` → prod. Per environment: secret `AWS_DEPLOY_ROLE_ARN` (OIDC role); optional `DOMAIN_NAME` var + `DOMAIN_CERTIFICATE_ARN` secret for a custom domain.
18
-
19
- The handler calls `app.create_app()` — the convention every `web/python/*` template follows.
20
-
21
- ## Files
22
-
23
- ```
24
- template.yaml # SAM resources: function, deps layer, HTTP API
25
- samconfig.toml # dev / prod stacks
26
- lambda_handler.py # Mangum adapter
27
- Makefile # SAM build recipes
28
- ```
29
-
30
- ## Requirements — IAM
31
-
32
- `requirements/` declares the least privilege the deploy role needs. Create it once per account:
33
-
34
- ```bash
35
- sed -i "s/ACCOUNT_ID/$(aws sts get-caller-identity --query Account --output text)/g" requirements/*.json
36
- aws iam create-role --role-name {{ cookiecutter.project_slug }}-deploy --assume-role-policy-document file://requirements/trust.json
37
- aws iam put-role-policy --role-name {{ cookiecutter.project_slug }}-deploy --policy-name deploy --policy-document file://requirements/policy.json
38
- ```
39
-
40
- `trust.json` trusts GitHub OIDC for this repo only. Put the role ARN in the `AWS_DEPLOY_ROLE_ARN` secret.
@@ -1,30 +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}}/template.yaml
23
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml
24
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile
25
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py
26
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py
27
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json
28
- apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json
29
- tests/test_proxy.py
30
- tests/test_targets.py
File without changes
File without changes