apx-aws-lambda 0.3.2__tar.gz → 0.3.4__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 (33) hide show
  1. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/PKG-INFO +4 -4
  2. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/README.md +2 -2
  3. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/lambda_.py +29 -15
  4. apx_aws_lambda-0.3.4/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +21 -0
  5. apx_aws_lambda-0.3.4/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +93 -0
  6. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml +3 -0
  7. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/plugin.py +15 -2
  8. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/shell.py +6 -14
  9. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda.egg-info/PKG-INFO +4 -4
  10. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda.egg-info/SOURCES.txt +1 -0
  11. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda.egg-info/requires.txt +1 -1
  12. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/pyproject.toml +2 -2
  13. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/tests/test_proxy.py +18 -0
  14. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/tests/test_targets.py +4 -10
  15. apx_aws_lambda-0.3.2/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -11
  16. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/LICENSE +0 -0
  17. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/__init__.py +0 -0
  18. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/cli.py +0 -0
  19. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
  20. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
  21. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
  22. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
  23. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
  24. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
  25. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
  26. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
  27. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/overlays/index.json +0 -0
  28. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/proxy.py +0 -0
  29. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda/tools.py +0 -0
  30. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
  31. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
  32. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/apx_aws_lambda.egg-info/top_level.txt +0 -0
  33. {apx_aws_lambda-0.3.2 → apx_aws_lambda-0.3.4}/setup.cfg +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.2
3
+ Version: 0.3.4
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.17
10
+ Requires-Dist: action-platform>=0.17.9
11
11
  Requires-Dist: awscli>=1.34
12
12
  Requires-Dist: aws-sam-cli>=1.120
13
13
  Provides-Extra: dev
@@ -71,7 +71,7 @@ The target looks for credentials in this order:
71
71
 
72
72
  | Under `[deploy]` | How | Who decides what the app may do |
73
73
  |---|---|---|
74
- | `proxy_url` + `app` | the deploy proxy in your account exchanges a platform token for the app's deploy-role credentials | the proxy's grants, in your account |
74
+ | `proxy_url` + `app` — or the organization's proxy url set on the platform (Plugins → AWS Lambda), which every deploy job carries as `AP_AWS_LAMBDA_PROXY_URL` with `AP_APP` | the deploy proxy in your account exchanges a platform token for the app's deploy-role credentials | the proxy's grants, in your account |
75
75
  | `role_arn` | `sts assume-role-with-web-identity` with a platform token | the role's trust and permission policies |
76
76
  | neither | the AWS CLI's own chain: SSO, profile, instance role | whatever that identity may do |
77
77
 
@@ -101,7 +101,7 @@ action-platform aws-lambda proxy show $P acme/shop/orders
101
101
 
102
102
  `create` makes the app's two roles and grants deploy to the app itself; `grant` replaces the list of subject prefixes that may deploy — `org:acme` means anyone in the organization, `org:acme:project:shop` any app of the project, the full subject only deploys the platform runs for that app.
103
103
 
104
- **3. Point the repository at it:**
104
+ **3. Tell the platform (or the repository) where it is.** On the hosted platform, **Plugins** → **AWS Lambda** → **Configure** keeps the proxy url for the whole organization; every deploy job then carries it, together with the app's `org/project/app`, so the repository needs nothing beyond `target = "aws/lambda"`. From a machine, or to override per repository:
105
105
 
106
106
  ```toml
107
107
  [deploy]
@@ -51,7 +51,7 @@ The target looks for credentials in this order:
51
51
 
52
52
  | Under `[deploy]` | How | Who decides what the app may do |
53
53
  |---|---|---|
54
- | `proxy_url` + `app` | the deploy proxy in your account exchanges a platform token for the app's deploy-role credentials | the proxy's grants, in your account |
54
+ | `proxy_url` + `app` — or the organization's proxy url set on the platform (Plugins → AWS Lambda), which every deploy job carries as `AP_AWS_LAMBDA_PROXY_URL` with `AP_APP` | the deploy proxy in your account exchanges a platform token for the app's deploy-role credentials | the proxy's grants, in your account |
55
55
  | `role_arn` | `sts assume-role-with-web-identity` with a platform token | the role's trust and permission policies |
56
56
  | neither | the AWS CLI's own chain: SSO, profile, instance role | whatever that identity may do |
57
57
 
@@ -81,7 +81,7 @@ action-platform aws-lambda proxy show $P acme/shop/orders
81
81
 
82
82
  `create` makes the app's two roles and grants deploy to the app itself; `grant` replaces the list of subject prefixes that may deploy — `org:acme` means anyone in the organization, `org:acme:project:shop` any app of the project, the full subject only deploys the platform runs for that app.
83
83
 
84
- **3. Point the repository at it:**
84
+ **3. Tell the platform (or the repository) where it is.** On the hosted platform, **Plugins** → **AWS Lambda** → **Configure** keeps the proxy url for the whole organization; every deploy job then carries it, together with the app's `org/project/app`, so the repository needs nothing beyond `target = "aws/lambda"`. From a machine, or to override per repository:
85
85
 
86
86
  ```toml
87
87
  [deploy]
@@ -37,27 +37,41 @@ class LambdaTarget(DeployTarget):
37
37
  self.config = config
38
38
  self.role_arn = role_arn or os.environ.get("AWS_ROLE_ARN")
39
39
  self.session_name = session_name
40
- self.proxy = (
41
- ProxyClient(proxy_url, app or os.environ.get("AP_APP", ""))
42
- if proxy_url
43
- else None
44
- )
40
+ self.proxy_url = proxy_url
41
+ self.app = app
45
42
  self._env: dict[str, str] | None = None
46
43
 
44
+ def proxy(self, ctx: Context) -> ProxyClient | None:
45
+ """The deploy proxy, when one is named: `[deploy] proxy_url` and `app` in platform.toml, else what the platform set for the organization (`AP_AWS_LAMBDA_PROXY_URL`, `AP_APP` in `ctx.env`), else the process environment."""
46
+ url = (
47
+ self.proxy_url
48
+ or ctx.env.get("AP_AWS_LAMBDA_PROXY_URL")
49
+ or os.environ.get("AP_AWS_LAMBDA_PROXY_URL")
50
+ )
51
+
52
+ if not url:
53
+ return None
54
+
55
+ app = self.app or ctx.env.get("AP_APP") or os.environ.get("AP_APP", "")
56
+
57
+ return ProxyClient(url, app)
58
+
47
59
  def env(self, ctx: Context) -> dict[str, str] | None:
48
60
  """The environment `aws` and `sam` run with: the proxy's credentials, else temporary credentials from `role_arn`, else the caller's own."""
49
- if self.proxy is None and not self.role_arn:
61
+ if self._env is not None:
62
+ return self._env
63
+
64
+ proxy = self.proxy(ctx)
65
+
66
+ if proxy is None and not self.role_arn:
50
67
  return None
51
68
 
52
- if self._env is None:
53
- granted = (
54
- self.proxy.env(ctx)
55
- if self.proxy is not None
56
- else assume_role(
57
- ctx, self.role_arn or "", self.session_name, self.region
58
- )
59
- )
60
- self._env = {**os.environ, **granted}
69
+ granted = (
70
+ proxy.env(ctx)
71
+ if proxy is not None
72
+ else assume_role(ctx, self.role_arn or "", self.session_name, self.region)
73
+ )
74
+ self._env = {**os.environ, **granted}
61
75
 
62
76
  return self._env
63
77
 
@@ -0,0 +1,21 @@
1
+ # SAM build recipes (BuildMethod: makefile). Deps go to a layer, code to the function.
2
+ # The layer is built for the function's platform (arm64, python3.12) from wheels only,
3
+ # so the build host — a laptop, CI, the platform's worker — does not matter.
4
+
5
+ LAYER_PLATFORM ?= manylinux2014_aarch64
6
+ LAYER_PYTHON ?= 3.12
7
+
8
+ build-ApiFunction:
9
+ cp -r app "$(ARTIFACTS_DIR)/app"
10
+ [ -d tools ] && cp -r tools "$(ARTIFACTS_DIR)/tools" || true
11
+ cp lambda_handler.py "$(ARTIFACTS_DIR)/lambda_handler.py"
12
+
13
+ build-DepsLayer:
14
+ mkdir -p "$(ARTIFACTS_DIR)/python"
15
+ python -m pip install --quiet --upgrade pip >/dev/null
16
+ python tools/lambda_requirements.py "$(ARTIFACTS_DIR)/requirements.txt"
17
+ python -m pip install --quiet --target "$(ARTIFACTS_DIR)/python" \
18
+ --platform "$(LAYER_PLATFORM)" --python-version "$(LAYER_PYTHON)" \
19
+ --implementation cp --only-binary=:all: \
20
+ mangum -r "$(ARTIFACTS_DIR)/requirements.txt"
21
+ rm -f "$(ARTIFACTS_DIR)/requirements.txt"
@@ -0,0 +1,93 @@
1
+ """Requirements for the Lambda layer without poetry on the build host: pins from poetry.lock when it exists, otherwise the main dependencies of pyproject.toml (PEP 621 or poetry's caret/tilde constraints turned into PEP 440)."""
2
+
3
+ import re
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ import tomllib
8
+
9
+
10
+ def caret(version: str) -> str:
11
+ parts = [int(p) for p in re.findall(r"\d+", version)]
12
+ upper = list(parts)
13
+
14
+ for i, p in enumerate(parts):
15
+ if p != 0 or i == len(parts) - 1:
16
+ upper = parts[:i] + [p + 1] + [0] * (len(parts) - i - 1)
17
+ break
18
+
19
+ return f">={version},<{'.'.join(str(p) for p in upper)}"
20
+
21
+
22
+ def tilde(version: str) -> str:
23
+ parts = [int(p) for p in re.findall(r"\d+", version)]
24
+ upper = parts[:1] + [parts[1] + 1] if len(parts) > 1 else [parts[0] + 1]
25
+
26
+ return f">={version},<{'.'.join(str(p) for p in upper)}"
27
+
28
+
29
+ def constraint(spec: str) -> str:
30
+ spec = spec.strip()
31
+
32
+ if spec in ("*", ""):
33
+ return ""
34
+
35
+ if spec.startswith("^"):
36
+ return caret(spec[1:])
37
+
38
+ if spec.startswith("~") and not spec.startswith("~="):
39
+ return tilde(spec[1:])
40
+
41
+ if re.match(r"^\d", spec):
42
+ return f"=={spec}"
43
+
44
+ return spec
45
+
46
+
47
+ def from_poetry(deps: dict) -> list[str]:
48
+ rows = []
49
+
50
+ for name, spec in deps.items():
51
+ if name.lower() == "python":
52
+ continue
53
+
54
+ extras = ""
55
+ version = spec
56
+
57
+ if isinstance(spec, dict):
58
+ if spec.get("optional"):
59
+ continue
60
+
61
+ version = spec.get("version", "*")
62
+ extras = (
63
+ f"[{','.join(spec['extras'])}]" if spec.get("extras") else ""
64
+ )
65
+
66
+ rows.append(f"{name}{extras}{constraint(str(version))}")
67
+
68
+ return rows
69
+
70
+
71
+ def main(out: str) -> None:
72
+ lock = Path("poetry.lock")
73
+
74
+ if lock.exists():
75
+ data = tomllib.loads(lock.read_text())
76
+ rows = [
77
+ f"{p['name']}=={p['version']}"
78
+ for p in data.get("package", [])
79
+ if "main" in (p.get("groups") or ["main"])
80
+ ]
81
+ else:
82
+ pyproject = tomllib.loads(Path("pyproject.toml").read_text())
83
+ rows = list(pyproject.get("project", {}).get("dependencies") or [])
84
+ rows += from_poetry(
85
+ pyproject.get("tool", {}).get("poetry", {}).get("dependencies")
86
+ or {}
87
+ )
88
+
89
+ Path(out).write_text("\n".join(rows) + "\n")
90
+
91
+
92
+ if __name__ == "__main__":
93
+ main(sys.argv[1])
@@ -47,6 +47,9 @@ Resources:
47
47
  Type: AWS::Serverless::Function
48
48
  Metadata:
49
49
  BuildMethod: makefile
50
+ cfn-lint:
51
+ config:
52
+ ignore_checks: [E3031]
50
53
  Properties:
51
54
  FunctionName: !Sub "${AWS::StackName}-api"
52
55
  CodeUri: .
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from pathlib import Path
6
6
 
7
- from action_platform.abc import Plugin, Surface
7
+ from action_platform.abc import Option, Plugin, Surface
8
8
 
9
9
  from apx_aws_lambda import cli
10
10
  from apx_aws_lambda.tools import register_tools
@@ -12,15 +12,28 @@ from apx_aws_lambda.tools import register_tools
12
12
 
13
13
  class AwsLambdaPlugin(Plugin):
14
14
  slug = "aws-lambda"
15
+ name = "AWS Lambda"
15
16
  description = (
16
17
  "Deploy to AWS Lambda with SAM; read CloudFormation stacks and functions"
17
18
  )
18
- min_core = "0.17"
19
+ min_core = "0.17.9"
19
20
  needs = [
20
21
  "tool: aws, sam (bundled as Python packages when not on PATH)",
21
22
  "env: AWS_REGION; credentials from proxy_url (the deploy proxy in your account, no keys), role_arn (OIDC, no keys) or the AWS CLI chain (SSO, profile, instance role)",
22
23
  "net: *.amazonaws.com, the proxy url when set",
23
24
  ]
25
+ options = [
26
+ Option(
27
+ "proxy_url",
28
+ "Deploy proxy URL",
29
+ "url",
30
+ help=(
31
+ "The deploy proxy installed in your AWS account: it decides which app may deploy and hands the worker short-lived credentials, so the platform never holds an access key. "
32
+ "Install it once with proxy/deploy.sh <platform url> <organization> from this repository; the Function URL it prints goes here."
33
+ ),
34
+ required=True,
35
+ ),
36
+ ]
24
37
 
25
38
  @property
26
39
  def overlays(self) -> Path:
@@ -12,7 +12,6 @@ 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.settings import settings
16
15
 
17
16
  MODULES = {"aws": "awscli", "sam": "samcli"}
18
17
 
@@ -32,19 +31,12 @@ def require(tool: str, hint: str) -> list[str]:
32
31
  raise DeployError(f"{tool} is not installed: {hint}")
33
32
 
34
33
 
35
- def module_env(args: list[str], env: dict[str, str] | None) -> dict[str, str] | None:
36
- """`python -m awscli` in a child process must see the plugins volume the parent added with `site.addsitedir`; PYTHONPATH carries it over."""
37
- if args[:1] != [sys.executable] or settings.PLUGINS_DIR is None:
38
- return env
34
+ def module_env(env: dict[str, str] | None) -> dict[str, str]:
35
+ """The child's environment: the caller's, or the process's, with SAM's telemetry off."""
36
+ if env is None:
37
+ return {**os.environ, "SAM_CLI_TELEMETRY": "0"}
39
38
 
40
- merged = dict(env if env is not None else os.environ)
41
- current = merged.get("PYTHONPATH", "")
42
- plugins = str(settings.PLUGINS_DIR)
43
-
44
- if plugins not in current.split(os.pathsep):
45
- merged["PYTHONPATH"] = os.pathsep.join(p for p in (plugins, current) if p)
46
-
47
- return merged
39
+ return {"SAM_CLI_TELEMETRY": "0", **env}
48
40
 
49
41
 
50
42
  def run(
@@ -53,7 +45,7 @@ def run(
53
45
  result = subprocess.run(
54
46
  args,
55
47
  cwd=cwd,
56
- env=module_env(args, env),
48
+ env=module_env(env),
57
49
  capture_output=True,
58
50
  text=True,
59
51
  check=False,
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.2
3
+ Version: 0.3.4
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.17
10
+ Requires-Dist: action-platform>=0.17.9
11
11
  Requires-Dist: awscli>=1.34
12
12
  Requires-Dist: aws-sam-cli>=1.120
13
13
  Provides-Extra: dev
@@ -71,7 +71,7 @@ The target looks for credentials in this order:
71
71
 
72
72
  | Under `[deploy]` | How | Who decides what the app may do |
73
73
  |---|---|---|
74
- | `proxy_url` + `app` | the deploy proxy in your account exchanges a platform token for the app's deploy-role credentials | the proxy's grants, in your account |
74
+ | `proxy_url` + `app` — or the organization's proxy url set on the platform (Plugins → AWS Lambda), which every deploy job carries as `AP_AWS_LAMBDA_PROXY_URL` with `AP_APP` | the deploy proxy in your account exchanges a platform token for the app's deploy-role credentials | the proxy's grants, in your account |
75
75
  | `role_arn` | `sts assume-role-with-web-identity` with a platform token | the role's trust and permission policies |
76
76
  | neither | the AWS CLI's own chain: SSO, profile, instance role | whatever that identity may do |
77
77
 
@@ -101,7 +101,7 @@ action-platform aws-lambda proxy show $P acme/shop/orders
101
101
 
102
102
  `create` makes the app's two roles and grants deploy to the app itself; `grant` replaces the list of subject prefixes that may deploy — `org:acme` means anyone in the organization, `org:acme:project:shop` any app of the project, the full subject only deploys the platform runs for that app.
103
103
 
104
- **3. Point the repository at it:**
104
+ **3. Tell the platform (or the repository) where it is.** On the hosted platform, **Plugins** → **AWS Lambda** → **Configure** keeps the proxy url for the whole organization; every deploy job then carries it, together with the app's `org/project/app`, so the repository needs nothing beyond `target = "aws/lambda"`. From a machine, or to override per repository:
105
105
 
106
106
  ```toml
107
107
  [deploy]
@@ -23,6 +23,7 @@ apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.
23
23
  apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml
24
24
  apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile
25
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
26
27
  apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json
27
28
  apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json
28
29
  tests/test_proxy.py
@@ -1,4 +1,4 @@
1
- action-platform>=0.17
1
+ action-platform>=0.17.9
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.2"
3
+ version = "0.3.4"
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.17", "awscli>=1.34", "aws-sam-cli>=1.120"]
9
+ dependencies = ["action-platform>=0.17.9", "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"]
@@ -108,6 +108,24 @@ class ProxyClientTest(unittest.TestCase):
108
108
 
109
109
  self.assertIn("update the proxy", str(caught.exception))
110
110
 
111
+ def test_the_platform_can_name_the_proxy_and_the_app(self):
112
+ (self.root / "samconfig.toml").write_text(
113
+ SAMCONFIG.format(stack="ap-acme-shop-orders-dev")
114
+ )
115
+ (self.root / "template.yaml").write_text("Resources: {}\n")
116
+ fake = FakeProxy({"POST /apps/acme/shop/orders/credentials": GRANTED})
117
+ ctx = self.ctx()
118
+ ctx.env = {
119
+ "AP_AWS_LAMBDA_PROXY_URL": "https://proxy.test",
120
+ "AP_APP": "acme/shop/orders",
121
+ }
122
+
123
+ with mock.patch("urllib.request.urlopen", fake):
124
+ env = LambdaTarget().env(ctx)
125
+
126
+ self.assertEqual(env["AWS_ACCESS_KEY_ID"], "AKIA")
127
+ self.assertEqual(fake.requests[-1][1], "/apps/acme/shop/orders/credentials")
128
+
111
129
  def test_app_must_be_three_parts(self):
112
130
  with self.assertRaises(DeployError):
113
131
  ProxyClient("https://proxy.test", "orders")
@@ -1,7 +1,6 @@
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
5
4
  import unittest
6
5
  from pathlib import Path
7
6
  from tempfile import TemporaryDirectory
@@ -11,7 +10,6 @@ from action_platform.core.context import Context
11
10
  from action_platform.core.exception import DeployError
12
11
  from action_platform.core.scaffold.templates import Matrix, with_plugin_clouds
13
12
  from action_platform.plugins import Loaded, Plugins, PluginState, registry
14
- from action_platform.settings import settings
15
13
 
16
14
  from apx_aws_lambda import AwsLambdaPlugin, shell
17
15
  from apx_aws_lambda.lambda_ import LambdaTarget
@@ -196,11 +194,7 @@ class AssumeRoleTest(unittest.TestCase):
196
194
 
197
195
 
198
196
  class ModuleEnvTest(unittest.TestCase):
199
- def test_the_plugins_volume_reaches_a_python_m_child(self):
200
- with mock.patch.object(settings, "PLUGINS_DIR", Path("/data/plugins")):
201
- env = shell.module_env([sys.executable, "-m", "awscli"], {"PATH": "/bin"})
202
- same = shell.module_env(["/usr/bin/aws"], {"PATH": "/bin"})
203
-
204
- self.assertEqual(env["PYTHONPATH"], "/data/plugins")
205
- self.assertEqual(env["PATH"], "/bin")
206
- self.assertEqual(same, {"PATH": "/bin"})
197
+ def test_the_child_gets_the_given_env_with_telemetry_off(self):
198
+ env = shell.module_env({"PATH": "/bin"})
199
+
200
+ self.assertEqual(env, {"PATH": "/bin", "SAM_CLI_TELEMETRY": "0"})
@@ -1,11 +0,0 @@
1
- # SAM build recipes (BuildMethod: makefile). Deps go to a layer, code to the function.
2
-
3
- build-ApiFunction:
4
- cp -r app "$(ARTIFACTS_DIR)/app"
5
- [ -d tools ] && cp -r tools "$(ARTIFACTS_DIR)/tools" || true
6
- cp lambda_handler.py "$(ARTIFACTS_DIR)/lambda_handler.py"
7
-
8
- build-DepsLayer:
9
- mkdir -p "$(ARTIFACTS_DIR)/python"
10
- poetry export --without dev,code-quality --without-hashes -f requirements.txt -o /tmp/requirements.txt
11
- pip install mangum -r /tmp/requirements.txt -t "$(ARTIFACTS_DIR)/python"
File without changes
File without changes