apx-aws-lambda 0.3.7__tar.gz → 0.3.9__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.7 → apx_aws_lambda-0.3.9}/PKG-INFO +2 -2
  2. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/README.md +1 -1
  3. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/lambda_.py +49 -0
  4. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +6 -1
  5. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +6 -1
  6. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +50 -0
  7. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/Makefile +6 -0
  8. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/cmd/lambda/main.go +25 -0
  9. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/template.yaml +97 -0
  10. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/Makefile +7 -0
  11. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/run.sh +2 -0
  12. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/template.yaml +105 -0
  13. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/Makefile +7 -0
  14. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/run.sh +2 -0
  15. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/template.yaml +105 -0
  16. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/Makefile +11 -0
  17. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/run.sh +2 -0
  18. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/template.yaml +102 -0
  19. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/Makefile +19 -0
  20. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/lambda_handler.rb +70 -0
  21. apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/template.yaml +99 -0
  22. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/index.json +6 -1
  23. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda.egg-info/PKG-INFO +2 -2
  24. apx_aws_lambda-0.3.9/apx_aws_lambda.egg-info/SOURCES.txt +45 -0
  25. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/pyproject.toml +1 -1
  26. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/tests/test_targets.py +54 -0
  27. apx_aws_lambda-0.3.7/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -40
  28. apx_aws_lambda-0.3.7/apx_aws_lambda.egg-info/SOURCES.txt +0 -30
  29. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/LICENSE +0 -0
  30. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/__init__.py +0 -0
  31. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/cli.py +0 -0
  32. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
  33. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -0
  34. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
  35. {apx_aws_lambda-0.3.7/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}} → apx_aws_lambda-0.3.9/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python}/template.yaml +0 -0
  36. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -0
  37. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
  38. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
  39. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
  40. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/plugin.py +0 -0
  41. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/proxy.py +0 -0
  42. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/shell.py +0 -0
  43. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda/tools.py +0 -0
  44. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
  45. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
  46. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda.egg-info/requires.txt +0 -0
  47. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/apx_aws_lambda.egg-info/top_level.txt +0 -0
  48. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/setup.cfg +0 -0
  49. {apx_aws_lambda-0.3.7 → apx_aws_lambda-0.3.9}/tests/test_proxy.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.7
3
+ Version: 0.3.9
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`, `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 |
@@ -27,7 +27,7 @@ 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 |
@@ -11,6 +11,7 @@ from dataclasses import replace
11
11
  from action_platform.abc import DeployTarget
12
12
  from action_platform.core.context import Context, DeployResult, Diagnosis
13
13
  from action_platform.core.exception import ActionPlatformError, DeployError
14
+ from action_platform.logging import logger
14
15
  from action_platform.remote.client import Remote
15
16
 
16
17
  from apx_aws_lambda import shell
@@ -154,11 +155,59 @@ class LambdaTarget(DeployTarget):
154
155
  env=self.env(ctx),
155
156
  )
156
157
 
158
+ def _status(self, ctx: Context) -> str | None:
159
+ """The stack's CloudFormation status, or None when there is no stack."""
160
+ try:
161
+ data = shell.aws(
162
+ "cloudformation",
163
+ "describe-stacks",
164
+ "--stack-name",
165
+ self._stack(ctx),
166
+ region=self._region(ctx),
167
+ env=self.env(ctx),
168
+ )
169
+ except DeployError:
170
+ return None
171
+
172
+ rows = data.get("Stacks") or []
173
+
174
+ return rows[0].get("StackStatus") if rows else None
175
+
176
+ def _clear_failed_creation(self, ctx: Context) -> None:
177
+ """A stack whose first creation failed sits in ROLLBACK_COMPLETE and refuses updates; it never existed, so it is deleted before the deploy creates it again."""
178
+ if self._status(ctx) != "ROLLBACK_COMPLETE":
179
+ return
180
+
181
+ stack = self._stack(ctx)
182
+ logger.info(
183
+ "stack %s is ROLLBACK_COMPLETE: deleting it before the deploy", stack
184
+ )
185
+ region = self._region(ctx)
186
+ env = self.env(ctx)
187
+ shell.aws(
188
+ "cloudformation",
189
+ "delete-stack",
190
+ "--stack-name",
191
+ stack,
192
+ region=region,
193
+ env=env,
194
+ )
195
+ shell.aws(
196
+ "cloudformation",
197
+ "wait",
198
+ "stack-delete-complete",
199
+ "--stack-name",
200
+ stack,
201
+ region=region,
202
+ env=env,
203
+ )
204
+
157
205
  def deploy(self, ctx: Context) -> DeployResult:
158
206
  sam = shell.require("sam", "pip install aws-sam-cli")
159
207
  stage = self._stage(ctx)
160
208
  env = self.env(ctx)
161
209
  shell.run([*sam, "build"], cwd=ctx.repo_root, env=env)
210
+ self._clear_failed_creation(ctx)
162
211
  args = [
163
212
  *sam,
164
213
  "deploy",
@@ -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,19 @@
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
@@ -0,0 +1,70 @@
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
@@ -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
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.7
3
+ Version: 0.3.9
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`, `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 |
@@ -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.7"
3
+ version = "0.3.9"
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"
@@ -90,6 +90,60 @@ class LambdaTargetTest(unittest.TestCase):
90
90
  self.assertEqual(result.url, "https://x")
91
91
  self.assertEqual(result.version, "1.2.0")
92
92
 
93
+ def test_a_stack_left_in_rollback_complete_is_deleted_before_the_deploy(self):
94
+ target = LambdaTarget()
95
+ statuses = iter(["ROLLBACK_COMPLETE", "UPDATE_COMPLETE"])
96
+
97
+ def run(args, cwd=None, env=None):
98
+ self.calls.append([Path(args[0]).name, *args[1:]])
99
+ key = " ".join(args[1:3])
100
+
101
+ if key == "cloudformation describe-stacks":
102
+ return json.dumps(
103
+ {
104
+ "Stacks": [
105
+ {
106
+ "StackStatus": next(statuses),
107
+ "Outputs": [
108
+ {"OutputKey": "ApiUrl", "OutputValue": "https://x"}
109
+ ],
110
+ }
111
+ ]
112
+ }
113
+ )
114
+
115
+ return "{}"
116
+
117
+ with mock.patch.multiple(
118
+ shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
119
+ ):
120
+ result = target.deploy(self.ctx("dev"))
121
+
122
+ names = [c[:3] for c in self.calls]
123
+ self.assertIn(["aws", "cloudformation", "delete-stack"], names)
124
+ self.assertIn(["aws", "cloudformation", "wait"], names)
125
+ self.assertLess(
126
+ names.index(["aws", "cloudformation", "delete-stack"]),
127
+ names.index(["sam", "deploy", "--no-confirm-changeset"]),
128
+ )
129
+ self.assertTrue(result.ok)
130
+
131
+ def test_a_healthy_stack_is_left_alone(self):
132
+ target = LambdaTarget()
133
+
134
+ with self.fake(
135
+ {
136
+ "cloudformation describe-stacks": {
137
+ "Stacks": [{"StackStatus": "UPDATE_COMPLETE", "Outputs": []}]
138
+ }
139
+ }
140
+ ):
141
+ target.deploy(self.ctx("dev"))
142
+
143
+ self.assertNotIn(
144
+ ["aws", "cloudformation", "delete-stack"], [c[:3] for c in self.calls]
145
+ )
146
+
93
147
  def test_diagnose_reads_the_stack(self):
94
148
  with self.fake(
95
149
  {
@@ -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