apx-aws-lambda 0.3.1__tar.gz → 0.3.3__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.
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/PKG-INFO +3 -3
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/README.md +2 -2
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/lambda_.py +29 -15
- apx_aws_lambda-0.3.3/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +21 -0
- apx_aws_lambda-0.3.3/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +93 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml +3 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/shell.py +27 -1
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda.egg-info/PKG-INFO +3 -3
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda.egg-info/SOURCES.txt +1 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/pyproject.toml +1 -1
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/tests/test_proxy.py +18 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/tests/test_targets.py +13 -0
- apx_aws_lambda-0.3.1/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -11
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/LICENSE +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/__init__.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/cli.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/overlays/index.json +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/plugin.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/proxy.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda/tools.py +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda.egg-info/requires.txt +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/apx_aws_lambda.egg-info/top_level.txt +0 -0
- {apx_aws_lambda-0.3.1 → apx_aws_lambda-0.3.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
|
@@ -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 (Settings → Integrations → AWS), 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.
|
|
104
|
+
**3. Tell the platform (or the repository) where it is.** On the hosted platform, Settings → Integrations → **AWS** 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 (Settings → Integrations → AWS), 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.
|
|
84
|
+
**3. Tell the platform (or the repository) where it is.** On the hosted platform, Settings → Integrations → **AWS** 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.
|
|
41
|
-
|
|
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.
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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])
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import importlib.util
|
|
6
6
|
import json
|
|
7
|
+
import os
|
|
7
8
|
import shutil
|
|
8
9
|
import subprocess
|
|
9
10
|
import sys
|
|
@@ -11,6 +12,7 @@ from pathlib import Path
|
|
|
11
12
|
from typing import Any
|
|
12
13
|
|
|
13
14
|
from action_platform.core.exception import DeployError
|
|
15
|
+
from action_platform.settings import settings
|
|
14
16
|
|
|
15
17
|
MODULES = {"aws": "awscli", "sam": "samcli"}
|
|
16
18
|
|
|
@@ -30,11 +32,35 @@ def require(tool: str, hint: str) -> list[str]:
|
|
|
30
32
|
raise DeployError(f"{tool} is not installed: {hint}")
|
|
31
33
|
|
|
32
34
|
|
|
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
|
+
if env is None:
|
|
39
|
+
return {**os.environ, "SAM_CLI_TELEMETRY": "0"}
|
|
40
|
+
|
|
41
|
+
return {"SAM_CLI_TELEMETRY": "0", **env}
|
|
42
|
+
|
|
43
|
+
merged = dict(env if env is not None else os.environ)
|
|
44
|
+
merged.setdefault("SAM_CLI_TELEMETRY", "0")
|
|
45
|
+
current = merged.get("PYTHONPATH", "")
|
|
46
|
+
plugins = str(settings.PLUGINS_DIR)
|
|
47
|
+
|
|
48
|
+
if plugins not in current.split(os.pathsep):
|
|
49
|
+
merged["PYTHONPATH"] = os.pathsep.join(p for p in (plugins, current) if p)
|
|
50
|
+
|
|
51
|
+
return merged
|
|
52
|
+
|
|
53
|
+
|
|
33
54
|
def run(
|
|
34
55
|
args: list[str], cwd: Path | None = None, env: dict[str, str] | None = None
|
|
35
56
|
) -> str:
|
|
36
57
|
result = subprocess.run(
|
|
37
|
-
args,
|
|
58
|
+
args,
|
|
59
|
+
cwd=cwd,
|
|
60
|
+
env=module_env(args, env),
|
|
61
|
+
capture_output=True,
|
|
62
|
+
text=True,
|
|
63
|
+
check=False,
|
|
38
64
|
)
|
|
39
65
|
|
|
40
66
|
if result.returncode != 0:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
|
@@ -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 (Settings → Integrations → AWS), 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.
|
|
104
|
+
**3. Tell the platform (or the repository) where it is.** On the hosted platform, Settings → Integrations → **AWS** 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
|
|
@@ -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,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
|
|
@@ -10,6 +11,7 @@ from action_platform.core.context import Context
|
|
|
10
11
|
from action_platform.core.exception import DeployError
|
|
11
12
|
from action_platform.core.scaffold.templates import Matrix, with_plugin_clouds
|
|
12
13
|
from action_platform.plugins import Loaded, Plugins, PluginState, registry
|
|
14
|
+
from action_platform.settings import settings
|
|
13
15
|
|
|
14
16
|
from apx_aws_lambda import AwsLambdaPlugin, shell
|
|
15
17
|
from apx_aws_lambda.lambda_ import LambdaTarget
|
|
@@ -191,3 +193,14 @@ class AssumeRoleTest(unittest.TestCase):
|
|
|
191
193
|
)
|
|
192
194
|
|
|
193
195
|
self.assertIn("log in", str(caught.exception))
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
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", "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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|