apx-aws-lambda 0.3.3__tar.gz → 0.3.5__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.3 → apx_aws_lambda-0.3.5}/PKG-INFO +5 -5
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/README.md +3 -3
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/lambda_.py +1 -1
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/plugin.py +15 -2
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/proxy.py +40 -8
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/shell.py +6 -18
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda.egg-info/PKG-INFO +5 -5
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda.egg-info/requires.txt +1 -1
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/pyproject.toml +2 -2
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/tests/test_proxy.py +77 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/tests/test_targets.py +4 -10
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/LICENSE +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/__init__.py +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/cli.py +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/overlays/index.json +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda/tools.py +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda.egg-info/SOURCES.txt +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/apx_aws_lambda.egg-info/top_level.txt +0 -0
- {apx_aws_lambda-0.3.3 → apx_aws_lambda-0.3.5}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
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` — or the organization's proxy url set on the platform (
|
|
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
|
|
|
@@ -89,7 +89,7 @@ cd apx-aws-lambda
|
|
|
89
89
|
|
|
90
90
|
The script runs `sam build` + `sam deploy`, prints the stack's `ProxyUrl` and calls `/health`.
|
|
91
91
|
|
|
92
|
-
**2. Register the app** — from a machine logged in to the platform (`action-platform login`) as someone with `org.manage
|
|
92
|
+
**2. Register the app** — happens by itself on the first deploy from the platform by someone with `org.manage`: the proxy answers 404 for an app it does not know, the plugin creates it (the deploy token carries `org.manage`) and goes on. Anyone else gets a readable refusal until a manager deploys once. From a machine logged in to the platform (`action-platform login`) as someone with `org.manage`, or to grant other subjects:
|
|
93
93
|
|
|
94
94
|
```bash
|
|
95
95
|
P=https://xxxx.lambda-url.us-east-1.on.aws
|
|
@@ -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. Tell the platform (or the repository) where it is.** On the hosted platform,
|
|
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` — or the organization's proxy url set on the platform (
|
|
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
|
|
|
@@ -69,7 +69,7 @@ cd apx-aws-lambda
|
|
|
69
69
|
|
|
70
70
|
The script runs `sam build` + `sam deploy`, prints the stack's `ProxyUrl` and calls `/health`.
|
|
71
71
|
|
|
72
|
-
**2. Register the app** — from a machine logged in to the platform (`action-platform login`) as someone with `org.manage
|
|
72
|
+
**2. Register the app** — happens by itself on the first deploy from the platform by someone with `org.manage`: the proxy answers 404 for an app it does not know, the plugin creates it (the deploy token carries `org.manage`) and goes on. Anyone else gets a readable refusal until a manager deploys once. From a machine logged in to the platform (`action-platform login`) as someone with `org.manage`, or to grant other subjects:
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
75
|
P=https://xxxx.lambda-url.us-east-1.on.aws
|
|
@@ -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. Tell the platform (or the repository) where it is.** On the hosted platform,
|
|
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]
|
|
@@ -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:
|
|
@@ -13,6 +13,13 @@ from action_platform.remote.client import Remote
|
|
|
13
13
|
MIN_PROXY = "0.1.0"
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class ProxyRefused(DeployError):
|
|
17
|
+
def __init__(self, status: int, detail: str, method: str, path: str) -> None:
|
|
18
|
+
super().__init__(f"proxy {method} {path}: {status} {detail}")
|
|
19
|
+
self.status = status
|
|
20
|
+
self.detail = detail
|
|
21
|
+
|
|
22
|
+
|
|
16
23
|
class ProxyClient:
|
|
17
24
|
def __init__(self, url: str, app: str, timeout: float = 20.0) -> None:
|
|
18
25
|
self.url = url.rstrip("/")
|
|
@@ -41,7 +48,10 @@ class ProxyClient:
|
|
|
41
48
|
def health(self) -> dict:
|
|
42
49
|
return self._call("GET", "/health")
|
|
43
50
|
|
|
44
|
-
def credentials(
|
|
51
|
+
def credentials(
|
|
52
|
+
self, ctx: Context, duration: int = 3600, region: str | None = None
|
|
53
|
+
) -> dict:
|
|
54
|
+
"""The app's credentials; an app the proxy does not know yet is registered first when the token may (`org.manage`) — the first deploy by an organization manager creates the roles."""
|
|
45
55
|
health = self.health()
|
|
46
56
|
|
|
47
57
|
if tuple_of(health.get("version", "0")) < tuple_of(MIN_PROXY):
|
|
@@ -49,20 +59,42 @@ class ProxyClient:
|
|
|
49
59
|
f"proxy {self.url} is {health.get('version')}; this plugin needs {MIN_PROXY} or newer — update the proxy stack"
|
|
50
60
|
)
|
|
51
61
|
|
|
62
|
+
token = self.token(ctx)
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
return self._credentials(token, duration)
|
|
66
|
+
except ProxyRefused as e:
|
|
67
|
+
if e.status != 404:
|
|
68
|
+
raise
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
self.create(region, token=token)
|
|
72
|
+
except ProxyRefused as e:
|
|
73
|
+
if e.status == 403:
|
|
74
|
+
raise DeployError(
|
|
75
|
+
f"the proxy does not know {self.app} yet, and this deploy may not register it ({e.detail}): "
|
|
76
|
+
"deploy once as an organization manager, or run `action-platform aws-lambda proxy create`"
|
|
77
|
+
) from e
|
|
78
|
+
|
|
79
|
+
raise
|
|
80
|
+
|
|
81
|
+
return self._credentials(token, duration)
|
|
82
|
+
|
|
83
|
+
def _credentials(self, token: str, duration: int) -> dict:
|
|
52
84
|
return self._call(
|
|
53
85
|
"POST",
|
|
54
86
|
f"/apps/{self.app}/credentials",
|
|
55
87
|
{"duration": duration},
|
|
56
|
-
token=
|
|
88
|
+
token=token,
|
|
57
89
|
)
|
|
58
90
|
|
|
59
|
-
def create(self, region: str | None = None) -> dict:
|
|
60
|
-
"""Admin: both roles for the app, granted to the app itself — the
|
|
91
|
+
def create(self, region: str | None = None, token: str | None = None) -> dict:
|
|
92
|
+
"""Admin: both roles for the app, granted to the app itself — the token must carry `org.manage`."""
|
|
61
93
|
return self._call(
|
|
62
94
|
"POST",
|
|
63
95
|
f"/apps/{self.app}",
|
|
64
96
|
{"region": region} if region else {},
|
|
65
|
-
token=self.token(),
|
|
97
|
+
token=token or self.token(),
|
|
66
98
|
)
|
|
67
99
|
|
|
68
100
|
def show(self) -> dict:
|
|
@@ -79,8 +111,8 @@ class ProxyClient:
|
|
|
79
111
|
token=self.token(),
|
|
80
112
|
)
|
|
81
113
|
|
|
82
|
-
def env(self, ctx: Context) -> dict[str, str]:
|
|
83
|
-
data = self.credentials(ctx)
|
|
114
|
+
def env(self, ctx: Context, region: str | None = None) -> dict[str, str]:
|
|
115
|
+
data = self.credentials(ctx, region=region)
|
|
84
116
|
|
|
85
117
|
return {
|
|
86
118
|
"AWS_ACCESS_KEY_ID": data["access_key_id"],
|
|
@@ -119,7 +151,7 @@ class ProxyClient:
|
|
|
119
151
|
except ValueError:
|
|
120
152
|
pass
|
|
121
153
|
|
|
122
|
-
raise
|
|
154
|
+
raise ProxyRefused(e.code, str(detail), method, path) from e
|
|
123
155
|
except urllib.error.URLError as e:
|
|
124
156
|
raise DeployError(f"proxy {self.url} unreachable: {e.reason}") from e
|
|
125
157
|
|
|
@@ -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,23 +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(
|
|
36
|
-
"""
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
return {**os.environ, "SAM_CLI_TELEMETRY": "0"}
|
|
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"}
|
|
40
38
|
|
|
41
|
-
|
|
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
|
|
39
|
+
return {"SAM_CLI_TELEMETRY": "0", **env}
|
|
52
40
|
|
|
53
41
|
|
|
54
42
|
def run(
|
|
@@ -57,7 +45,7 @@ def run(
|
|
|
57
45
|
result = subprocess.run(
|
|
58
46
|
args,
|
|
59
47
|
cwd=cwd,
|
|
60
|
-
env=module_env(
|
|
48
|
+
env=module_env(env),
|
|
61
49
|
capture_output=True,
|
|
62
50
|
text=True,
|
|
63
51
|
check=False,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
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` — or the organization's proxy url set on the platform (
|
|
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
|
|
|
@@ -89,7 +89,7 @@ cd apx-aws-lambda
|
|
|
89
89
|
|
|
90
90
|
The script runs `sam build` + `sam deploy`, prints the stack's `ProxyUrl` and calls `/health`.
|
|
91
91
|
|
|
92
|
-
**2. Register the app** — from a machine logged in to the platform (`action-platform login`) as someone with `org.manage
|
|
92
|
+
**2. Register the app** — happens by itself on the first deploy from the platform by someone with `org.manage`: the proxy answers 404 for an app it does not know, the plugin creates it (the deploy token carries `org.manage`) and goes on. Anyone else gets a readable refusal until a manager deploys once. From a machine logged in to the platform (`action-platform login`) as someone with `org.manage`, or to grant other subjects:
|
|
93
93
|
|
|
94
94
|
```bash
|
|
95
95
|
P=https://xxxx.lambda-url.us-east-1.on.aws
|
|
@@ -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. Tell the platform (or the repository) where it is.** On the hosted platform,
|
|
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]
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "apx-aws-lambda"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.5"
|
|
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"]
|
|
@@ -99,6 +99,83 @@ class ProxyClientTest(unittest.TestCase):
|
|
|
99
99
|
|
|
100
100
|
self.assertIn("403 nope", str(caught.exception))
|
|
101
101
|
|
|
102
|
+
def test_an_unknown_app_is_registered_on_the_way_when_the_token_may(self):
|
|
103
|
+
fake = FakeProxy({"POST /apps/acme/shop/orders": {"created": True}})
|
|
104
|
+
credentials = "POST /apps/acme/shop/orders/credentials"
|
|
105
|
+
|
|
106
|
+
def answer(request, timeout=None):
|
|
107
|
+
if (
|
|
108
|
+
f"{request.get_method()} {request.full_url.split('proxy.test', 1)[1]}"
|
|
109
|
+
== credentials
|
|
110
|
+
and credentials not in fake.answers
|
|
111
|
+
):
|
|
112
|
+
fake.answers[credentials] = GRANTED
|
|
113
|
+
fake.requests.append(
|
|
114
|
+
(
|
|
115
|
+
request.get_method(),
|
|
116
|
+
"/apps/acme/shop/orders/credentials",
|
|
117
|
+
None,
|
|
118
|
+
None,
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
raise urllib.error.HTTPError(
|
|
122
|
+
request.full_url,
|
|
123
|
+
404,
|
|
124
|
+
"no",
|
|
125
|
+
{},
|
|
126
|
+
io.BytesIO(b'{"error":"no app acme/shop/orders; create it first"}'),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return fake(request, timeout)
|
|
130
|
+
|
|
131
|
+
with mock.patch("urllib.request.urlopen", answer):
|
|
132
|
+
env = ProxyClient("https://proxy.test", "acme/shop/orders").env(
|
|
133
|
+
self.ctx(), "eu-west-1"
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
self.assertEqual(env["AWS_ACCESS_KEY_ID"], "AKIA")
|
|
137
|
+
self.assertEqual(
|
|
138
|
+
[(m, p, b) for m, p, b, _ in fake.requests[1:]],
|
|
139
|
+
[
|
|
140
|
+
("POST", "/apps/acme/shop/orders/credentials", None),
|
|
141
|
+
("POST", "/apps/acme/shop/orders", {"region": "eu-west-1"}),
|
|
142
|
+
("POST", "/apps/acme/shop/orders/credentials", {"duration": 3600}),
|
|
143
|
+
],
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def test_an_unknown_app_the_token_may_not_register_is_a_readable_error(self):
|
|
147
|
+
fake = FakeProxy({})
|
|
148
|
+
|
|
149
|
+
def answer(request, timeout=None):
|
|
150
|
+
path = request.full_url.split("proxy.test", 1)[1]
|
|
151
|
+
|
|
152
|
+
if path.endswith("/credentials"):
|
|
153
|
+
raise urllib.error.HTTPError(
|
|
154
|
+
request.full_url,
|
|
155
|
+
404,
|
|
156
|
+
"no",
|
|
157
|
+
{},
|
|
158
|
+
io.BytesIO(b'{"error":"no app; create it first"}'),
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
if path == "/apps/acme/shop/orders":
|
|
162
|
+
raise urllib.error.HTTPError(
|
|
163
|
+
request.full_url,
|
|
164
|
+
403,
|
|
165
|
+
"no",
|
|
166
|
+
{},
|
|
167
|
+
io.BytesIO(b'{"error":"org.manage is required"}'),
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
return fake(request, timeout)
|
|
171
|
+
|
|
172
|
+
with mock.patch("urllib.request.urlopen", answer):
|
|
173
|
+
with self.assertRaises(DeployError) as caught:
|
|
174
|
+
ProxyClient("https://proxy.test", "acme/shop/orders").env(self.ctx())
|
|
175
|
+
|
|
176
|
+
self.assertIn("organization manager", str(caught.exception))
|
|
177
|
+
self.assertIn("org.manage is required", str(caught.exception))
|
|
178
|
+
|
|
102
179
|
def test_an_old_proxy_is_refused(self):
|
|
103
180
|
fake = FakeProxy({}, version="0.0.1")
|
|
104
181
|
|
|
@@ -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
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
self.assertEqual(env["PYTHONPATH"], "/data/plugins")
|
|
205
|
-
self.assertEqual(env["PATH"], "/bin")
|
|
206
|
-
self.assertEqual(same, {"PATH": "/bin", "SAM_CLI_TELEMETRY": "0"})
|
|
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"})
|
|
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
|
|
File without changes
|