apx-aws-lambda 0.3.11__tar.gz → 0.4.1__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 (47) hide show
  1. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/PKG-INFO +3 -3
  2. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/README.md +1 -1
  3. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/shell.py +12 -0
  4. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda.egg-info/PKG-INFO +3 -3
  5. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda.egg-info/requires.txt +1 -1
  6. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/pyproject.toml +2 -2
  7. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/tests/test_targets.py +44 -0
  8. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/LICENSE +0 -0
  9. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/__init__.py +0 -0
  10. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/cli.py +0 -0
  11. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/lambda_.py +0 -0
  12. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
  13. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
  14. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
  15. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
  16. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/Makefile +0 -0
  17. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/cmd/lambda/main.go +0 -0
  18. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/template.yaml +0 -0
  19. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/Makefile +0 -0
  20. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/run.sh +0 -0
  21. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/template.yaml +0 -0
  22. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/Makefile +0 -0
  23. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/run.sh +0 -0
  24. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/template.yaml +0 -0
  25. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/Makefile +0 -0
  26. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/run.sh +0 -0
  27. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/template.yaml +0 -0
  28. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -0
  29. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
  30. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/template.yaml +0 -0
  31. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -0
  32. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/Makefile +0 -0
  33. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/lambda_handler.rb +0 -0
  34. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/template.yaml +0 -0
  35. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
  36. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
  37. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
  38. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/overlays/index.json +0 -0
  39. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/plugin.py +0 -0
  40. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/proxy.py +0 -0
  41. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda/tools.py +0 -0
  42. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda.egg-info/SOURCES.txt +0 -0
  43. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
  44. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
  45. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/apx_aws_lambda.egg-info/top_level.txt +0 -0
  46. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/setup.cfg +0 -0
  47. {apx_aws_lambda-0.3.11 → apx_aws_lambda-0.4.1}/tests/test_proxy.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.11
3
+ Version: 0.4.1
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
7
7
  Requires-Python: >=3.11
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
- Requires-Dist: action-platform>=0.22.0
10
+ Requires-Dist: action-platform>=0.23.0
11
11
  Requires-Dist: awscli>=1.34
12
12
  Requires-Dist: aws-sam-cli>=1.120
13
13
  Provides-Extra: dev
@@ -49,7 +49,7 @@ action-platform diagnose
49
49
  |---|---|
50
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
  | Readiness | before a deploy, without building or changing anything: the tooling is there, the overlay is applied, the stack name resolves, the credentials work, the stack is not mid-operation or failed (a `ROLLBACK_COMPLETE` first creation is a warning — the deploy deletes it), the deploy role may do what the template needs (simulated with `iam:SimulatePrincipalPolicy` against the stack, the function, its log group, the execution role and every public layer the template references — the Lambda Web Adapter's, for one) and `sam validate --lint` passes. The platform runs it after every release for `dev` and `prod` and refuses a blocked deploy unless forced; `action-platform readiness` runs it on a machine |
52
- | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first |
52
+ | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
53
53
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
54
54
  | Diagnose | stack status and the HTTP API url |
55
55
  | 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 |
@@ -29,7 +29,7 @@ action-platform diagnose
29
29
  |---|---|
30
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
  | Readiness | before a deploy, without building or changing anything: the tooling is there, the overlay is applied, the stack name resolves, the credentials work, the stack is not mid-operation or failed (a `ROLLBACK_COMPLETE` first creation is a warning — the deploy deletes it), the deploy role may do what the template needs (simulated with `iam:SimulatePrincipalPolicy` against the stack, the function, its log group, the execution role and every public layer the template references — the Lambda Web Adapter's, for one) and `sam validate --lint` passes. The platform runs it after every release for `dev` and `prod` and refuses a blocked deploy unless forced; `action-platform readiness` runs it on a machine |
32
- | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first |
32
+ | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
33
33
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
34
34
  | Diagnose | stack status and the HTTP API url |
35
35
  | 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 |
@@ -12,6 +12,7 @@ from pathlib import Path
12
12
  from typing import Any
13
13
 
14
14
  from action_platform.core.exception import DeployError
15
+ from action_platform.core.process import stream
15
16
 
16
17
  MODULES = {"aws": "awscli", "sam": "samcli"}
17
18
 
@@ -42,6 +43,17 @@ def module_env(env: dict[str, str] | None) -> dict[str, str]:
42
43
  def run(
43
44
  args: list[str], cwd: Path | None = None, env: dict[str, str] | None = None
44
45
  ) -> str:
46
+ """`sam` streams: every line goes to whoever follows the job as it appears. `aws` answers JSON and is read whole."""
47
+ if Path(args[0]).name == "sam" or (len(args) > 2 and args[2] == "samcli"):
48
+ result = stream(args, cwd=cwd, env=module_env(env))
49
+
50
+ if not result.ok:
51
+ raise DeployError(
52
+ f"{' '.join(args[:2])} failed: {result.output.strip()[-2000:]}"
53
+ )
54
+
55
+ return result.output
56
+
45
57
  result = subprocess.run(
46
58
  args,
47
59
  cwd=cwd,
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.11
3
+ Version: 0.4.1
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
7
7
  Requires-Python: >=3.11
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
- Requires-Dist: action-platform>=0.22.0
10
+ Requires-Dist: action-platform>=0.23.0
11
11
  Requires-Dist: awscli>=1.34
12
12
  Requires-Dist: aws-sam-cli>=1.120
13
13
  Provides-Extra: dev
@@ -49,7 +49,7 @@ action-platform diagnose
49
49
  |---|---|
50
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
  | Readiness | before a deploy, without building or changing anything: the tooling is there, the overlay is applied, the stack name resolves, the credentials work, the stack is not mid-operation or failed (a `ROLLBACK_COMPLETE` first creation is a warning — the deploy deletes it), the deploy role may do what the template needs (simulated with `iam:SimulatePrincipalPolicy` against the stack, the function, its log group, the execution role and every public layer the template references — the Lambda Web Adapter's, for one) and `sam validate --lint` passes. The platform runs it after every release for `dev` and `prod` and refuses a blocked deploy unless forced; `action-platform readiness` runs it on a machine |
52
- | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first |
52
+ | Deploy | `sam build` + `sam deploy --config-env <stage>` (`dev` → `default`, `prod` → `prod`); a stack left in `ROLLBACK_COMPLETE` by a failed first creation is deleted first. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
53
53
  | Rollback | CloudFormation `rollback-stack` — previous stack state |
54
54
  | Diagnose | stack status and the HTTP API url |
55
55
  | 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 |
@@ -1,4 +1,4 @@
1
- action-platform>=0.22.0
1
+ action-platform>=0.23.0
2
2
  awscli>=1.34
3
3
  aws-sam-cli>=1.120
4
4
 
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "apx-aws-lambda"
3
- version = "0.3.11"
3
+ version = "0.4.1"
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"
7
7
  requires-python = ">=3.11"
8
8
  authors = [{ name = "Action Platform", email = "cloud@actionplatform.io" }]
9
- dependencies = ["action-platform>=0.22.0", "awscli>=1.34", "aws-sam-cli>=1.120"]
9
+ dependencies = ["action-platform>=0.23.0", "awscli>=1.34", "aws-sam-cli>=1.120"]
10
10
 
11
11
  [project.optional-dependencies]
12
12
  dev = ["pytest>=8", "ruff>=0.6", "action-platform[mcp]", "boto3>=1.34", "cryptography>=42"]
@@ -1,6 +1,7 @@
1
1
  """The target drives `aws` and `sam`; here both are fakes, so what is asserted is the sequence and the answers."""
2
2
 
3
3
  import json
4
+ import sys
4
5
  import unittest
5
6
  from pathlib import Path
6
7
  from tempfile import TemporaryDirectory
@@ -361,3 +362,46 @@ class ModuleEnvTest(unittest.TestCase):
361
362
  env = shell.module_env({"PATH": "/bin"})
362
363
 
363
364
  self.assertEqual(env, {"PATH": "/bin", "SAM_CLI_TELEMETRY": "0"})
365
+
366
+
367
+ class ShellStreamsSamTest(unittest.TestCase):
368
+ def sam(self, script: str) -> list[str]:
369
+ return [sys.executable, "-m", "samcli", "-u", "-c", script]
370
+
371
+ def test_sam_output_reaches_the_log_sink_line_by_line(self):
372
+ from action_platform.core.process import Completed
373
+ from action_platform.logging import capture
374
+
375
+ seen: list[str] = []
376
+
377
+ def fake_stream(args, cwd=None, env=None, tail=60):
378
+ for line in ("Building", "Build Succeeded"):
379
+ from action_platform.logging import emit
380
+
381
+ emit(line)
382
+
383
+ return Completed(0, "Building\nBuild Succeeded")
384
+
385
+ with mock.patch.object(shell, "stream", fake_stream), capture(seen.append):
386
+ out = shell.run(self.sam("x"))
387
+
388
+ self.assertEqual(seen, ["Building", "Build Succeeded"])
389
+ self.assertEqual(out.splitlines()[-1], "Build Succeeded")
390
+
391
+ def test_a_failing_sam_keeps_the_tail_in_the_error(self):
392
+ from action_platform.core.process import Completed
393
+
394
+ with mock.patch.object(
395
+ shell, "stream", return_value=Completed(2, "step 1\nboom")
396
+ ):
397
+ with self.assertRaises(DeployError) as caught:
398
+ shell.run(self.sam("x"))
399
+
400
+ self.assertIn("boom", str(caught.exception))
401
+
402
+ def test_aws_is_read_whole_not_streamed(self):
403
+ with mock.patch.object(shell, "stream") as streamed:
404
+ out = shell.run([sys.executable, "-c", "print('{\"ok\": 1}')"])
405
+
406
+ streamed.assert_not_called()
407
+ self.assertEqual(out.strip(), '{"ok": 1}')
File without changes