apx-aws-lambda 0.3.10__tar.gz → 0.4.0__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.10 → apx_aws_lambda-0.4.0}/PKG-INFO +8 -5
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/README.md +6 -3
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/lambda_.py +198 -1
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/proxy.py +1 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/shell.py +12 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda.egg-info/PKG-INFO +8 -5
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda.egg-info/requires.txt +1 -1
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/pyproject.toml +2 -2
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/tests/test_targets.py +151 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/LICENSE +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/__init__.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/cli.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/Makefile +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/cmd/lambda/main.go +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/go/template.yaml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/Makefile +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/run.sh +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/java/template.yaml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/Makefile +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/run.sh +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/kotlin/template.yaml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/Makefile +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/run.sh +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/node/template.yaml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/template.yaml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/Makefile +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/lambda_handler.rb +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/ruby/template.yaml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/overlays/index.json +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/plugin.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda/tools.py +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda.egg-info/SOURCES.txt +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/apx_aws_lambda.egg-info/top_level.txt +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/setup.cfg +0 -0
- {apx_aws_lambda-0.3.10 → apx_aws_lambda-0.4.0}/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
|
+
Version: 0.4.0
|
|
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.
|
|
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
|
|
@@ -48,7 +48,8 @@ action-platform diagnose
|
|
|
48
48
|
| | |
|
|
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. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
|
|
52
53
|
| Rollback | CloudFormation `rollback-stack` — previous stack state |
|
|
53
54
|
| Diagnose | stack status and the HTTP API url |
|
|
54
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 |
|
|
@@ -178,11 +179,13 @@ Parameters: `IssuerUrl` (the platform's public url), `Organization` (one proxy s
|
|
|
178
179
|
|
|
179
180
|
| Role | Trust | Policy |
|
|
180
181
|
|---|---|---|
|
|
181
|
-
| `ap-deploy-<org>-<project>-<app>` | the proxy's function role | CloudFormation on stacks `ap-<org>-<project>-<app>*`; Lambda, API Gateway and logs with the same prefix; `iam:PassRole` on the execution role; SAM's managed bucket |
|
|
182
|
+
| `ap-deploy-<org>-<project>-<app>` | the proxy's function role | CloudFormation on stacks `ap-<org>-<project>-<app>*`; Lambda, API Gateway and logs with the same prefix; `lambda:GetLayerVersion` on the public Lambda Web Adapter layers (account `753240598075`); `iam:PassRole` on the execution role; `iam:SimulatePrincipalPolicy` on itself, for readiness; SAM's managed bucket |
|
|
182
183
|
| `ap-exec-<org>-<project>-<app>` | `lambda.amazonaws.com` | `AWSLambdaBasicExecutionRole` + the boundary |
|
|
183
184
|
|
|
184
185
|
Both live under `/action-platform/`, carry tags `action-platform:app` and `action-platform:prefix`, and are idempotent: `create` again syncs trust policies, tags and policies without duplicating anything. `delete` removes both and the grants.
|
|
185
186
|
|
|
187
|
+
The deploy policy carries a version. An app registered by an older proxy gets its policy rewritten the first time it asks for credentials after the proxy was redeployed, so a wider policy reaches existing apps without re-registering them.
|
|
188
|
+
|
|
186
189
|
### The boundary
|
|
187
190
|
|
|
188
191
|
`ActionPlatformBoundary` is one policy for every app, scoped per app by the role's `action-platform:prefix` tag used as a policy variable in the resources:
|
|
@@ -202,7 +205,7 @@ POST /apps/{org}/{project}/{app} create both roles; body {"regio
|
|
|
202
205
|
GET /apps/{org}/{project}/{app} roles and grants org.manage
|
|
203
206
|
DELETE /apps/{org}/{project}/{app} delete roles and grants org.manage
|
|
204
207
|
PUT /apps/{org}/{project}/{app}/grants {"subjects": ["org:acme", …]} org.manage
|
|
205
|
-
POST /apps/{org}/{project}/{app}/credentials {"duration": 900..3600} → temporary credentials a grant
|
|
208
|
+
POST /apps/{org}/{project}/{app}/credentials {"duration": 900..3600} → temporary credentials, stack_prefix, execution_role, deploy_role a grant
|
|
206
209
|
```
|
|
207
210
|
|
|
208
211
|
Every call except `/health` carries `Authorization: Bearer <platform token>` with `aud` = the proxy url. The proxy checks the signature against the issuer's JWKS, `iss`, `aud`, expiry, and that `organization` is the one it serves. Admin calls need `org.manage` in the token's `scopes`; deploy-job tokens carry no scopes, so a compromised worker cannot widen a grant. `credentials` needs the token's `sub` to start with one of the app's granted subject prefixes.
|
|
@@ -28,7 +28,8 @@ action-platform diagnose
|
|
|
28
28
|
| | |
|
|
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. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
|
|
32
33
|
| Rollback | CloudFormation `rollback-stack` — previous stack state |
|
|
33
34
|
| Diagnose | stack status and the HTTP API url |
|
|
34
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 |
|
|
@@ -158,11 +159,13 @@ Parameters: `IssuerUrl` (the platform's public url), `Organization` (one proxy s
|
|
|
158
159
|
|
|
159
160
|
| Role | Trust | Policy |
|
|
160
161
|
|---|---|---|
|
|
161
|
-
| `ap-deploy-<org>-<project>-<app>` | the proxy's function role | CloudFormation on stacks `ap-<org>-<project>-<app>*`; Lambda, API Gateway and logs with the same prefix; `iam:PassRole` on the execution role; SAM's managed bucket |
|
|
162
|
+
| `ap-deploy-<org>-<project>-<app>` | the proxy's function role | CloudFormation on stacks `ap-<org>-<project>-<app>*`; Lambda, API Gateway and logs with the same prefix; `lambda:GetLayerVersion` on the public Lambda Web Adapter layers (account `753240598075`); `iam:PassRole` on the execution role; `iam:SimulatePrincipalPolicy` on itself, for readiness; SAM's managed bucket |
|
|
162
163
|
| `ap-exec-<org>-<project>-<app>` | `lambda.amazonaws.com` | `AWSLambdaBasicExecutionRole` + the boundary |
|
|
163
164
|
|
|
164
165
|
Both live under `/action-platform/`, carry tags `action-platform:app` and `action-platform:prefix`, and are idempotent: `create` again syncs trust policies, tags and policies without duplicating anything. `delete` removes both and the grants.
|
|
165
166
|
|
|
167
|
+
The deploy policy carries a version. An app registered by an older proxy gets its policy rewritten the first time it asks for credentials after the proxy was redeployed, so a wider policy reaches existing apps without re-registering them.
|
|
168
|
+
|
|
166
169
|
### The boundary
|
|
167
170
|
|
|
168
171
|
`ActionPlatformBoundary` is one policy for every app, scoped per app by the role's `action-platform:prefix` tag used as a policy variable in the resources:
|
|
@@ -182,7 +185,7 @@ POST /apps/{org}/{project}/{app} create both roles; body {"regio
|
|
|
182
185
|
GET /apps/{org}/{project}/{app} roles and grants org.manage
|
|
183
186
|
DELETE /apps/{org}/{project}/{app} delete roles and grants org.manage
|
|
184
187
|
PUT /apps/{org}/{project}/{app}/grants {"subjects": ["org:acme", …]} org.manage
|
|
185
|
-
POST /apps/{org}/{project}/{app}/credentials {"duration": 900..3600} → temporary credentials a grant
|
|
188
|
+
POST /apps/{org}/{project}/{app}/credentials {"duration": 900..3600} → temporary credentials, stack_prefix, execution_role, deploy_role a grant
|
|
186
189
|
```
|
|
187
190
|
|
|
188
191
|
Every call except `/health` carries `Authorization: Bearer <platform token>` with `aud` = the proxy url. The proxy checks the signature against the issuer's JWKS, `iss`, `aud`, expiry, and that `organization` is the one it serves. Admin calls need `org.manage` in the token's `scopes`; deploy-job tokens carry no scopes, so a compromised worker cannot widen a grant. `credentials` needs the token's `sub` to start with one of the app's granted subject prefixes.
|
|
@@ -5,11 +5,12 @@ Credentials, in order: `proxy_url` + `app` under `[deploy]` — the deploy proxy
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
|
+
import re
|
|
8
9
|
import tomllib
|
|
9
10
|
from dataclasses import replace
|
|
10
11
|
|
|
11
12
|
from action_platform.abc import DeployTarget
|
|
12
|
-
from action_platform.core.context import Context, DeployResult, Diagnosis
|
|
13
|
+
from action_platform.core.context import Check, Context, DeployResult, Diagnosis
|
|
13
14
|
from action_platform.core.exception import ActionPlatformError, DeployError
|
|
14
15
|
from action_platform.logging import logger
|
|
15
16
|
from action_platform.remote.client import Remote
|
|
@@ -155,6 +156,196 @@ class LambdaTarget(DeployTarget):
|
|
|
155
156
|
env=self.env(ctx),
|
|
156
157
|
)
|
|
157
158
|
|
|
159
|
+
def readiness(self, ctx: Context) -> list[Check]:
|
|
160
|
+
checks: list[Check] = []
|
|
161
|
+
|
|
162
|
+
for tool, hint in (
|
|
163
|
+
("sam", "pip install aws-sam-cli"),
|
|
164
|
+
("aws", "https://aws.amazon.com/cli/"),
|
|
165
|
+
):
|
|
166
|
+
try:
|
|
167
|
+
shell.require(tool, hint)
|
|
168
|
+
checks.append(Check(f"tool.{tool}", True, "installed"))
|
|
169
|
+
except DeployError as e:
|
|
170
|
+
checks.append(Check(f"tool.{tool}", False, str(e), fix=hint))
|
|
171
|
+
|
|
172
|
+
if not (ctx.repo_root / "template.yaml").exists():
|
|
173
|
+
checks.append(
|
|
174
|
+
Check(
|
|
175
|
+
"template.present",
|
|
176
|
+
False,
|
|
177
|
+
"template.yaml not found",
|
|
178
|
+
fix="apply the aws/lambda overlay: action-platform cloud set aws/lambda",
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
return checks
|
|
183
|
+
|
|
184
|
+
try:
|
|
185
|
+
stack = self._stack(ctx)
|
|
186
|
+
checks.append(Check("stack.name", True, stack))
|
|
187
|
+
except DeployError as e:
|
|
188
|
+
checks.append(Check("stack.name", False, str(e), fix="fill samconfig.toml"))
|
|
189
|
+
|
|
190
|
+
return checks
|
|
191
|
+
|
|
192
|
+
try:
|
|
193
|
+
env = self.env(ctx)
|
|
194
|
+
identity = shell.aws(
|
|
195
|
+
"sts", "get-caller-identity", region=self._region(ctx), env=env
|
|
196
|
+
)
|
|
197
|
+
checks.append(
|
|
198
|
+
Check("aws.credentials", True, identity.get("Arn", "credentials work"))
|
|
199
|
+
)
|
|
200
|
+
except (DeployError, ProxyRefused) as e:
|
|
201
|
+
checks.append(
|
|
202
|
+
Check(
|
|
203
|
+
"aws.credentials",
|
|
204
|
+
False,
|
|
205
|
+
str(e),
|
|
206
|
+
fix="connect the deploy proxy or a role for this app in the AWS Lambda plugin",
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
return checks
|
|
211
|
+
|
|
212
|
+
checks.append(self._stack_state(ctx))
|
|
213
|
+
checks.extend(self._permissions(ctx, env, identity, stack))
|
|
214
|
+
checks.append(self._template_valid(ctx, env))
|
|
215
|
+
|
|
216
|
+
return checks
|
|
217
|
+
|
|
218
|
+
def _stack_state(self, ctx: Context) -> Check:
|
|
219
|
+
status = self._status(ctx)
|
|
220
|
+
|
|
221
|
+
if status is None:
|
|
222
|
+
return Check("stack.state", True, "no stack yet; the deploy creates it")
|
|
223
|
+
|
|
224
|
+
if status == "ROLLBACK_COMPLETE":
|
|
225
|
+
return Check(
|
|
226
|
+
"stack.state",
|
|
227
|
+
True,
|
|
228
|
+
f"{status}: the failed first creation is deleted before the deploy",
|
|
229
|
+
severity="warning",
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
if status.endswith("_IN_PROGRESS"):
|
|
233
|
+
return Check(
|
|
234
|
+
"stack.state",
|
|
235
|
+
False,
|
|
236
|
+
f"{status}: another operation is running on the stack",
|
|
237
|
+
fix="wait for it to finish, or cancel it in CloudFormation",
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
if status.endswith("_FAILED"):
|
|
241
|
+
return Check(
|
|
242
|
+
"stack.state",
|
|
243
|
+
False,
|
|
244
|
+
status,
|
|
245
|
+
fix="the stack needs attention in CloudFormation before a deploy can update it",
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
return Check("stack.state", True, status)
|
|
249
|
+
|
|
250
|
+
def _permissions(
|
|
251
|
+
self, ctx: Context, env: dict[str, str] | None, identity: dict, stack: str
|
|
252
|
+
) -> list[Check]:
|
|
253
|
+
role = (env or {}).get("AP_DEPLOY_ROLE") or _role_of(identity.get("Arn", ""))
|
|
254
|
+
|
|
255
|
+
if not role:
|
|
256
|
+
return []
|
|
257
|
+
|
|
258
|
+
account = identity.get("Account", "")
|
|
259
|
+
region = self._region(ctx) or "us-east-1"
|
|
260
|
+
wanted: list[tuple[list[str], list[str]]] = [
|
|
261
|
+
(
|
|
262
|
+
["cloudformation:CreateChangeSet", "cloudformation:DescribeStacks"],
|
|
263
|
+
[f"arn:aws:cloudformation:{region}:{account}:stack/{stack}/*"],
|
|
264
|
+
),
|
|
265
|
+
(
|
|
266
|
+
["lambda:CreateFunction", "lambda:UpdateFunctionCode"],
|
|
267
|
+
[f"arn:aws:lambda:{region}:{account}:function:{stack}-ApiFunction"],
|
|
268
|
+
),
|
|
269
|
+
(
|
|
270
|
+
["logs:CreateLogGroup"],
|
|
271
|
+
[
|
|
272
|
+
f"arn:aws:logs:{region}:{account}:log-group:/aws/lambda/{stack}-ApiFunction"
|
|
273
|
+
],
|
|
274
|
+
),
|
|
275
|
+
]
|
|
276
|
+
layers = self._layers(ctx, region)
|
|
277
|
+
|
|
278
|
+
if layers:
|
|
279
|
+
wanted.append((["lambda:GetLayerVersion"], layers))
|
|
280
|
+
|
|
281
|
+
execution = (env or {}).get("AP_EXECUTION_ROLE")
|
|
282
|
+
|
|
283
|
+
if execution:
|
|
284
|
+
wanted.append((["iam:PassRole"], [execution]))
|
|
285
|
+
|
|
286
|
+
denied: list[str] = []
|
|
287
|
+
|
|
288
|
+
for actions, resources in wanted:
|
|
289
|
+
try:
|
|
290
|
+
data = shell.aws(
|
|
291
|
+
"iam",
|
|
292
|
+
"simulate-principal-policy",
|
|
293
|
+
"--policy-source-arn",
|
|
294
|
+
role,
|
|
295
|
+
"--action-names",
|
|
296
|
+
*actions,
|
|
297
|
+
"--resource-arns",
|
|
298
|
+
*resources,
|
|
299
|
+
env=env,
|
|
300
|
+
)
|
|
301
|
+
except DeployError as e:
|
|
302
|
+
return [
|
|
303
|
+
Check(
|
|
304
|
+
"aws.permissions",
|
|
305
|
+
True,
|
|
306
|
+
f"not simulated: {str(e)[:200]}",
|
|
307
|
+
severity="warning",
|
|
308
|
+
)
|
|
309
|
+
]
|
|
310
|
+
|
|
311
|
+
for row in data.get("EvaluationResults") or []:
|
|
312
|
+
if row.get("EvalDecision") != "allowed":
|
|
313
|
+
denied.append(
|
|
314
|
+
f"{row.get('EvalActionName')} on {row.get('EvalResourceName')}"
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
if denied:
|
|
318
|
+
return [
|
|
319
|
+
Check(
|
|
320
|
+
"aws.permissions",
|
|
321
|
+
False,
|
|
322
|
+
f"{role} may not: " + "; ".join(denied),
|
|
323
|
+
fix="widen the deploy role's policy (redeploy the deploy proxy when it created the role)",
|
|
324
|
+
)
|
|
325
|
+
]
|
|
326
|
+
|
|
327
|
+
return [Check("aws.permissions", True, f"{role} may deploy {stack}")]
|
|
328
|
+
|
|
329
|
+
def _layers(self, ctx: Context, region: str) -> list[str]:
|
|
330
|
+
text = (ctx.repo_root / "template.yaml").read_text(errors="replace")
|
|
331
|
+
text = text.replace("${AWS::Region}", region)
|
|
332
|
+
|
|
333
|
+
return sorted(
|
|
334
|
+
set(re.findall(r"arn:aws:lambda:[\w-]+:\d{12}:layer:[\w-]+:\d+", text))
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
def _template_valid(self, ctx: Context, env: dict[str, str] | None) -> Check:
|
|
338
|
+
try:
|
|
339
|
+
shell.run(
|
|
340
|
+
[*shell.require("sam", ""), "validate", "--lint"],
|
|
341
|
+
cwd=ctx.repo_root,
|
|
342
|
+
env=env,
|
|
343
|
+
)
|
|
344
|
+
except DeployError as e:
|
|
345
|
+
return Check("template.valid", False, str(e), fix="fix template.yaml")
|
|
346
|
+
|
|
347
|
+
return Check("template.valid", True, "sam validate --lint passes")
|
|
348
|
+
|
|
158
349
|
def _status(self, ctx: Context) -> str | None:
|
|
159
350
|
"""The stack's CloudFormation status, or None when there is no stack."""
|
|
160
351
|
try:
|
|
@@ -325,6 +516,12 @@ class LambdaTarget(DeployTarget):
|
|
|
325
516
|
return None
|
|
326
517
|
|
|
327
518
|
|
|
519
|
+
def _role_of(arn: str) -> str | None:
|
|
520
|
+
found = re.match(r"^arn:aws:sts::(\d+):assumed-role/([^/]+)/", arn)
|
|
521
|
+
|
|
522
|
+
return f"arn:aws:iam::{found.group(1)}:role/{found.group(2)}" if found else None
|
|
523
|
+
|
|
524
|
+
|
|
328
525
|
def assume_role(
|
|
329
526
|
ctx: Context, role_arn: str, session_name: str, region: str | None
|
|
330
527
|
) -> dict[str, str]:
|
|
@@ -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
|
+
Version: 0.4.0
|
|
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.
|
|
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
|
|
@@ -48,7 +48,8 @@ action-platform diagnose
|
|
|
48
48
|
| | |
|
|
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. Every line `sam` prints reaches the platform's run log as it appears — the deploy form, the run dialog, `action-platform logs -f` |
|
|
52
53
|
| Rollback | CloudFormation `rollback-stack` — previous stack state |
|
|
53
54
|
| Diagnose | stack status and the HTTP API url |
|
|
54
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 |
|
|
@@ -178,11 +179,13 @@ Parameters: `IssuerUrl` (the platform's public url), `Organization` (one proxy s
|
|
|
178
179
|
|
|
179
180
|
| Role | Trust | Policy |
|
|
180
181
|
|---|---|---|
|
|
181
|
-
| `ap-deploy-<org>-<project>-<app>` | the proxy's function role | CloudFormation on stacks `ap-<org>-<project>-<app>*`; Lambda, API Gateway and logs with the same prefix; `iam:PassRole` on the execution role; SAM's managed bucket |
|
|
182
|
+
| `ap-deploy-<org>-<project>-<app>` | the proxy's function role | CloudFormation on stacks `ap-<org>-<project>-<app>*`; Lambda, API Gateway and logs with the same prefix; `lambda:GetLayerVersion` on the public Lambda Web Adapter layers (account `753240598075`); `iam:PassRole` on the execution role; `iam:SimulatePrincipalPolicy` on itself, for readiness; SAM's managed bucket |
|
|
182
183
|
| `ap-exec-<org>-<project>-<app>` | `lambda.amazonaws.com` | `AWSLambdaBasicExecutionRole` + the boundary |
|
|
183
184
|
|
|
184
185
|
Both live under `/action-platform/`, carry tags `action-platform:app` and `action-platform:prefix`, and are idempotent: `create` again syncs trust policies, tags and policies without duplicating anything. `delete` removes both and the grants.
|
|
185
186
|
|
|
187
|
+
The deploy policy carries a version. An app registered by an older proxy gets its policy rewritten the first time it asks for credentials after the proxy was redeployed, so a wider policy reaches existing apps without re-registering them.
|
|
188
|
+
|
|
186
189
|
### The boundary
|
|
187
190
|
|
|
188
191
|
`ActionPlatformBoundary` is one policy for every app, scoped per app by the role's `action-platform:prefix` tag used as a policy variable in the resources:
|
|
@@ -202,7 +205,7 @@ POST /apps/{org}/{project}/{app} create both roles; body {"regio
|
|
|
202
205
|
GET /apps/{org}/{project}/{app} roles and grants org.manage
|
|
203
206
|
DELETE /apps/{org}/{project}/{app} delete roles and grants org.manage
|
|
204
207
|
PUT /apps/{org}/{project}/{app}/grants {"subjects": ["org:acme", …]} org.manage
|
|
205
|
-
POST /apps/{org}/{project}/{app}/credentials {"duration": 900..3600} → temporary credentials a grant
|
|
208
|
+
POST /apps/{org}/{project}/{app}/credentials {"duration": 900..3600} → temporary credentials, stack_prefix, execution_role, deploy_role a grant
|
|
206
209
|
```
|
|
207
210
|
|
|
208
211
|
Every call except `/health` carries `Authorization: Bearer <platform token>` with `aud` = the proxy url. The proxy checks the signature against the issuer's JWKS, `iss`, `aud`, expiry, and that `organization` is the one it serves. Admin calls need `org.manage` in the token's `scopes`; deploy-job tokens carry no scopes, so a compromised worker cannot widen a grant. `credentials` needs the token's `sub` to start with one of the app's granted subject prefixes.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "apx-aws-lambda"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
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.
|
|
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
|
|
@@ -144,6 +145,113 @@ class LambdaTargetTest(unittest.TestCase):
|
|
|
144
145
|
["aws", "cloudformation", "delete-stack"], [c[:3] for c in self.calls]
|
|
145
146
|
)
|
|
146
147
|
|
|
148
|
+
def test_readiness_reports_credentials_state_permissions_and_template(self):
|
|
149
|
+
(self.root / "template.yaml").write_text(
|
|
150
|
+
"Resources:\n Fn:\n Properties:\n Layers:\n"
|
|
151
|
+
" - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:25\n"
|
|
152
|
+
)
|
|
153
|
+
target = LambdaTarget(region="us-east-1")
|
|
154
|
+
target._env = {
|
|
155
|
+
"AP_DEPLOY_ROLE": "arn:aws:iam::1:role/action-platform/ap-deploy-x",
|
|
156
|
+
"AP_EXECUTION_ROLE": "arn:aws:iam::1:role/action-platform/ap-exec-x",
|
|
157
|
+
"AP_STACK_PREFIX": "ap-x",
|
|
158
|
+
}
|
|
159
|
+
simulated: list[list[str]] = []
|
|
160
|
+
|
|
161
|
+
def run(args, cwd=None, env=None):
|
|
162
|
+
self.calls.append([Path(args[0]).name, *args[1:]])
|
|
163
|
+
key = " ".join(args[1:3])
|
|
164
|
+
|
|
165
|
+
if key == "sts get-caller-identity":
|
|
166
|
+
return json.dumps(
|
|
167
|
+
{"Account": "1", "Arn": "arn:aws:sts::1:assumed-role/ap-deploy-x/p"}
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if key == "cloudformation describe-stacks":
|
|
171
|
+
return json.dumps({"Stacks": [{"StackStatus": "UPDATE_COMPLETE"}]})
|
|
172
|
+
|
|
173
|
+
if key == "iam simulate-principal-policy":
|
|
174
|
+
simulated.append(args)
|
|
175
|
+
actions = args[
|
|
176
|
+
args.index("--action-names") + 1 : args.index("--resource-arns")
|
|
177
|
+
]
|
|
178
|
+
resources = args[
|
|
179
|
+
args.index("--resource-arns") + 1 : args.index("--output")
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
return json.dumps(
|
|
183
|
+
{
|
|
184
|
+
"EvaluationResults": [
|
|
185
|
+
{
|
|
186
|
+
"EvalActionName": a,
|
|
187
|
+
"EvalResourceName": r,
|
|
188
|
+
"EvalDecision": "implicitDeny"
|
|
189
|
+
if a == "lambda:GetLayerVersion"
|
|
190
|
+
else "allowed",
|
|
191
|
+
}
|
|
192
|
+
for a in actions
|
|
193
|
+
for r in resources
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
return "{}"
|
|
199
|
+
|
|
200
|
+
with mock.patch.multiple(
|
|
201
|
+
shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
|
|
202
|
+
):
|
|
203
|
+
checks = {c.id: c for c in target.readiness(self.ctx("prod"))}
|
|
204
|
+
|
|
205
|
+
self.assertTrue(checks["aws.credentials"].ok)
|
|
206
|
+
self.assertEqual(checks["stack.name"].detail, "ap-x-prod")
|
|
207
|
+
self.assertTrue(checks["stack.state"].ok)
|
|
208
|
+
self.assertFalse(checks["aws.permissions"].ok)
|
|
209
|
+
self.assertIn("lambda:GetLayerVersion", checks["aws.permissions"].detail)
|
|
210
|
+
self.assertIn("LambdaAdapterLayerArm64:25", checks["aws.permissions"].detail)
|
|
211
|
+
self.assertTrue(checks["template.valid"].ok)
|
|
212
|
+
self.assertTrue(
|
|
213
|
+
any("iam:PassRole" in args for args in simulated),
|
|
214
|
+
"the execution role's PassRole is simulated",
|
|
215
|
+
)
|
|
216
|
+
self.assertNotIn(["sam", "build"], [c[:2] for c in self.calls])
|
|
217
|
+
|
|
218
|
+
def test_readiness_flags_a_stack_with_an_operation_in_progress(self):
|
|
219
|
+
target = LambdaTarget(region="us-east-1")
|
|
220
|
+
|
|
221
|
+
with self.fake(
|
|
222
|
+
{
|
|
223
|
+
"sts get-caller-identity": {
|
|
224
|
+
"Account": "1",
|
|
225
|
+
"Arn": "arn:aws:iam::1:user/me",
|
|
226
|
+
},
|
|
227
|
+
"cloudformation describe-stacks": {
|
|
228
|
+
"Stacks": [{"StackStatus": "UPDATE_IN_PROGRESS"}]
|
|
229
|
+
},
|
|
230
|
+
}
|
|
231
|
+
):
|
|
232
|
+
checks = {c.id: c for c in target.readiness(self.ctx("dev"))}
|
|
233
|
+
|
|
234
|
+
self.assertFalse(checks["stack.state"].ok)
|
|
235
|
+
self.assertIn("UPDATE_IN_PROGRESS", checks["stack.state"].detail)
|
|
236
|
+
self.assertNotIn("aws.permissions", checks)
|
|
237
|
+
|
|
238
|
+
def test_readiness_without_credentials_stops_there(self):
|
|
239
|
+
target = LambdaTarget(region="us-east-1")
|
|
240
|
+
|
|
241
|
+
def run(args, cwd=None, env=None):
|
|
242
|
+
if " ".join(args[1:3]) == "sts get-caller-identity":
|
|
243
|
+
raise DeployError("aws sts failed: Unable to locate credentials")
|
|
244
|
+
|
|
245
|
+
return "{}"
|
|
246
|
+
|
|
247
|
+
with mock.patch.multiple(
|
|
248
|
+
shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
|
|
249
|
+
):
|
|
250
|
+
checks = target.readiness(self.ctx("dev"))
|
|
251
|
+
|
|
252
|
+
self.assertEqual(checks[-1].id, "aws.credentials")
|
|
253
|
+
self.assertFalse(checks[-1].ok)
|
|
254
|
+
|
|
147
255
|
def test_diagnose_reads_the_stack(self):
|
|
148
256
|
with self.fake(
|
|
149
257
|
{
|
|
@@ -254,3 +362,46 @@ class ModuleEnvTest(unittest.TestCase):
|
|
|
254
362
|
env = shell.module_env({"PATH": "/bin"})
|
|
255
363
|
|
|
256
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
|
|
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
|
|
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
|