apx-aws-lambda 1.2.0__tar.gz → 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/PKG-INFO +2 -2
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/README.md +1 -1
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/lambda_.py +8 -7
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda.egg-info/PKG-INFO +2 -2
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/pyproject.toml +1 -1
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/tests/test_targets.py +36 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/LICENSE +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/__init__.py +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/cli.py +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/connect/template.yaml +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/Makefile +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/overlays/index.json +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/plugin.py +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/shell.py +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda/tools.py +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda.egg-info/SOURCES.txt +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda.egg-info/requires.txt +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/apx_aws_lambda.egg-info/top_level.txt +0 -0
- {apx_aws_lambda-1.2.0 → apx_aws_lambda-1.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: AWS Lambda for Action Platform: the aws/lambda deploy target (SAM) with its overlay, and tools to read stacks and functions.
|
|
5
5
|
Author-email: Action Platform <cloud@actionplatform.io>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -93,7 +93,7 @@ What the stack creates:
|
|
|
93
93
|
| `ActionPlatformAppBoundary` (`/action-platform/`) | the cap on every execution role an app's stack creates — logs `/aws/lambda/<prefix>*`; S3 buckets, DynamoDB tables, SQS queues, SNS topics, Lambda functions `<prefix>-*`; Secrets Manager secrets and SSM parameters `<prefix>/*`; X-Ray — `<prefix>` being the role's `action-platform:prefix` tag. An app's own `template.yaml` still declares what its function needs; the boundary caps it |
|
|
94
94
|
| `ActionPlatformDeploy` role (`/action-platform/`) | trust: `AssumeRoleWithWebIdentity` for `sub` `org:<org>:*`, and `TagSession` only for the one tag `action-platform:prefix` with a value `ap-<org>-*`. Policy: every resource under `${aws:PrincipalTag/action-platform:prefix}` — CloudFormation stacks, Lambda, logs; API Gateway; the public Lambda Web Adapter layers; SAM's bucket; `iam:CreateRole` on `<prefix>-*` only with the boundary attached and the app's own prefix tag, `iam:PassRole` of those roles to Lambda only; `iam:SimulatePrincipalPolicy` on itself |
|
|
95
95
|
|
|
96
|
-
How a deploy runs: the platform signs a token for the app with the claim `https://aws.amazon.com/tags` → `principal_tags.action-platform:prefix = ap-<org>-<project>-<app>`; the target assumes the deploy role with it, names the stack `ap-<org>-<project>-<app
|
|
96
|
+
How a deploy runs: the platform signs a token for the app with the claim `https://aws.amazon.com/tags` → `principal_tags.action-platform:prefix = ap-<org>-<project>-<app>`; the target assumes the deploy role with it, names the stack `ap-<org>-<project>-<app>-<scope>`, passes `PermissionsBoundaryArn` to the overlay's template and tags the stack with the prefix, so the execution role SAM creates carries both the boundary and the tag. `sam delete` removes that role with the stack. Who may deploy which app is the platform's decision — it only signs a token for an app the job or the caller is for.
|
|
97
97
|
|
|
98
98
|
Readiness simulates the deploy role with the session tag and the boundary as context entries, and flags an overlay without the `PermissionsBoundaryArn` parameter (apply the overlay again). The stack's policy is the one place to widen or narrow what deploys may do: edit and update the stack.
|
|
99
99
|
|
|
@@ -75,7 +75,7 @@ What the stack creates:
|
|
|
75
75
|
| `ActionPlatformAppBoundary` (`/action-platform/`) | the cap on every execution role an app's stack creates — logs `/aws/lambda/<prefix>*`; S3 buckets, DynamoDB tables, SQS queues, SNS topics, Lambda functions `<prefix>-*`; Secrets Manager secrets and SSM parameters `<prefix>/*`; X-Ray — `<prefix>` being the role's `action-platform:prefix` tag. An app's own `template.yaml` still declares what its function needs; the boundary caps it |
|
|
76
76
|
| `ActionPlatformDeploy` role (`/action-platform/`) | trust: `AssumeRoleWithWebIdentity` for `sub` `org:<org>:*`, and `TagSession` only for the one tag `action-platform:prefix` with a value `ap-<org>-*`. Policy: every resource under `${aws:PrincipalTag/action-platform:prefix}` — CloudFormation stacks, Lambda, logs; API Gateway; the public Lambda Web Adapter layers; SAM's bucket; `iam:CreateRole` on `<prefix>-*` only with the boundary attached and the app's own prefix tag, `iam:PassRole` of those roles to Lambda only; `iam:SimulatePrincipalPolicy` on itself |
|
|
77
77
|
|
|
78
|
-
How a deploy runs: the platform signs a token for the app with the claim `https://aws.amazon.com/tags` → `principal_tags.action-platform:prefix = ap-<org>-<project>-<app>`; the target assumes the deploy role with it, names the stack `ap-<org>-<project>-<app
|
|
78
|
+
How a deploy runs: the platform signs a token for the app with the claim `https://aws.amazon.com/tags` → `principal_tags.action-platform:prefix = ap-<org>-<project>-<app>`; the target assumes the deploy role with it, names the stack `ap-<org>-<project>-<app>-<scope>`, passes `PermissionsBoundaryArn` to the overlay's template and tags the stack with the prefix, so the execution role SAM creates carries both the boundary and the tag. `sam delete` removes that role with the stack. Who may deploy which app is the platform's decision — it only signs a token for an app the job or the caller is for.
|
|
79
79
|
|
|
80
80
|
Readiness simulates the deploy role with the session tag and the boundary as context entries, and flags an overlay without the `PermissionsBoundaryArn` parameter (apply the overlay again). The stack's policy is the one place to widen or narrow what deploys may do: edit and update the stack.
|
|
81
81
|
|
|
@@ -17,6 +17,7 @@ from action_platform.remote.client import Remote
|
|
|
17
17
|
from apx_aws_lambda import shell
|
|
18
18
|
|
|
19
19
|
BOUNDARY = "policy/action-platform/ActionPlatformAppBoundary"
|
|
20
|
+
FAILED_CREATION = ("ROLLBACK_COMPLETE", "ROLLBACK_FAILED")
|
|
20
21
|
PREFIX_TAG = "action-platform:prefix"
|
|
21
22
|
|
|
22
23
|
|
|
@@ -109,7 +110,7 @@ class LambdaTarget(DeployTarget):
|
|
|
109
110
|
prefix = (self.env(ctx) or {}).get("AP_STACK_PREFIX")
|
|
110
111
|
|
|
111
112
|
if prefix:
|
|
112
|
-
return f"{prefix}-{
|
|
113
|
+
return f"{prefix}-{ctx.stage or 'dev'}"
|
|
113
114
|
|
|
114
115
|
params = (
|
|
115
116
|
self._samconfig(ctx)
|
|
@@ -277,7 +278,7 @@ class LambdaTarget(DeployTarget):
|
|
|
277
278
|
if status is None:
|
|
278
279
|
return Check("stack.state", True, "no stack yet; the deploy creates it")
|
|
279
280
|
|
|
280
|
-
if status
|
|
281
|
+
if status in FAILED_CREATION:
|
|
281
282
|
return Check(
|
|
282
283
|
"stack.state",
|
|
283
284
|
True,
|
|
@@ -430,14 +431,14 @@ class LambdaTarget(DeployTarget):
|
|
|
430
431
|
return rows[0].get("StackStatus") if rows else None
|
|
431
432
|
|
|
432
433
|
def _clear_failed_creation(self, ctx: Context) -> None:
|
|
433
|
-
"""A stack whose first creation failed sits in ROLLBACK_COMPLETE and refuses updates; it never existed, so it is deleted before the deploy creates it again."""
|
|
434
|
-
|
|
434
|
+
"""A stack whose first creation failed sits in ROLLBACK_COMPLETE — or ROLLBACK_FAILED when a resource could not be rolled back — and refuses updates; it never existed, so it is deleted before the deploy creates it again."""
|
|
435
|
+
status = self._status(ctx)
|
|
436
|
+
|
|
437
|
+
if status not in FAILED_CREATION:
|
|
435
438
|
return
|
|
436
439
|
|
|
437
440
|
stack = self._stack(ctx)
|
|
438
|
-
logger.info(
|
|
439
|
-
"stack %s is ROLLBACK_COMPLETE: deleting it before the deploy", stack
|
|
440
|
-
)
|
|
441
|
+
logger.info("stack %s is %s: deleting it before the deploy", stack, status)
|
|
441
442
|
region = self._region(ctx)
|
|
442
443
|
env = self.env(ctx)
|
|
443
444
|
shell.aws(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: AWS Lambda for Action Platform: the aws/lambda deploy target (SAM) with its overlay, and tools to read stacks and functions.
|
|
5
5
|
Author-email: Action Platform <cloud@actionplatform.io>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -93,7 +93,7 @@ What the stack creates:
|
|
|
93
93
|
| `ActionPlatformAppBoundary` (`/action-platform/`) | the cap on every execution role an app's stack creates — logs `/aws/lambda/<prefix>*`; S3 buckets, DynamoDB tables, SQS queues, SNS topics, Lambda functions `<prefix>-*`; Secrets Manager secrets and SSM parameters `<prefix>/*`; X-Ray — `<prefix>` being the role's `action-platform:prefix` tag. An app's own `template.yaml` still declares what its function needs; the boundary caps it |
|
|
94
94
|
| `ActionPlatformDeploy` role (`/action-platform/`) | trust: `AssumeRoleWithWebIdentity` for `sub` `org:<org>:*`, and `TagSession` only for the one tag `action-platform:prefix` with a value `ap-<org>-*`. Policy: every resource under `${aws:PrincipalTag/action-platform:prefix}` — CloudFormation stacks, Lambda, logs; API Gateway; the public Lambda Web Adapter layers; SAM's bucket; `iam:CreateRole` on `<prefix>-*` only with the boundary attached and the app's own prefix tag, `iam:PassRole` of those roles to Lambda only; `iam:SimulatePrincipalPolicy` on itself |
|
|
95
95
|
|
|
96
|
-
How a deploy runs: the platform signs a token for the app with the claim `https://aws.amazon.com/tags` → `principal_tags.action-platform:prefix = ap-<org>-<project>-<app>`; the target assumes the deploy role with it, names the stack `ap-<org>-<project>-<app
|
|
96
|
+
How a deploy runs: the platform signs a token for the app with the claim `https://aws.amazon.com/tags` → `principal_tags.action-platform:prefix = ap-<org>-<project>-<app>`; the target assumes the deploy role with it, names the stack `ap-<org>-<project>-<app>-<scope>`, passes `PermissionsBoundaryArn` to the overlay's template and tags the stack with the prefix, so the execution role SAM creates carries both the boundary and the tag. `sam delete` removes that role with the stack. Who may deploy which app is the platform's decision — it only signs a token for an app the job or the caller is for.
|
|
97
97
|
|
|
98
98
|
Readiness simulates the deploy role with the session tag and the boundary as context entries, and flags an overlay without the `PermissionsBoundaryArn` parameter (apply the overlay again). The stack's policy is the one place to widen or narrow what deploys may do: edit and update the stack.
|
|
99
99
|
|
|
@@ -131,6 +131,29 @@ class LambdaTargetTest(unittest.TestCase):
|
|
|
131
131
|
)
|
|
132
132
|
self.assertTrue(result.ok)
|
|
133
133
|
|
|
134
|
+
def test_a_stack_left_in_rollback_failed_is_deleted_before_the_deploy(self):
|
|
135
|
+
target = LambdaTarget()
|
|
136
|
+
statuses = iter(["ROLLBACK_FAILED", "UPDATE_COMPLETE"])
|
|
137
|
+
|
|
138
|
+
def run(args, cwd=None, env=None):
|
|
139
|
+
self.calls.append([Path(args[0]).name, *args[1:]])
|
|
140
|
+
|
|
141
|
+
if " ".join(args[1:3]) == "cloudformation describe-stacks":
|
|
142
|
+
return json.dumps(
|
|
143
|
+
{"Stacks": [{"StackStatus": next(statuses), "Outputs": []}]}
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return "{}"
|
|
147
|
+
|
|
148
|
+
with mock.patch.multiple(
|
|
149
|
+
shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
|
|
150
|
+
):
|
|
151
|
+
target.deploy(self.ctx("dev"))
|
|
152
|
+
|
|
153
|
+
self.assertIn(
|
|
154
|
+
["aws", "cloudformation", "delete-stack"], [c[:3] for c in self.calls]
|
|
155
|
+
)
|
|
156
|
+
|
|
134
157
|
def test_a_healthy_stack_is_left_alone(self):
|
|
135
158
|
target = LambdaTarget()
|
|
136
159
|
|
|
@@ -450,6 +473,19 @@ class ConnectedAccountTest(unittest.TestCase):
|
|
|
450
473
|
"Project=shop Environment=dev action-platform:prefix=ap-acme-shop-orders",
|
|
451
474
|
)
|
|
452
475
|
|
|
476
|
+
def test_the_stack_is_named_after_the_scope(self):
|
|
477
|
+
ctx = self.ctx()
|
|
478
|
+
ctx.stage = "production"
|
|
479
|
+
|
|
480
|
+
with self.patched():
|
|
481
|
+
LambdaTarget().deploy(ctx)
|
|
482
|
+
|
|
483
|
+
deploy = next(c for c in self.calls if c[:2] == ["sam", "deploy"])
|
|
484
|
+
self.assertEqual(
|
|
485
|
+
deploy[deploy.index("--stack-name") + 1],
|
|
486
|
+
"ap-acme-shop-orders-production",
|
|
487
|
+
)
|
|
488
|
+
|
|
453
489
|
def test_readiness_simulates_with_the_session_tag_and_the_boundary(self):
|
|
454
490
|
with self.patched():
|
|
455
491
|
checks = {c.id: c for c in LambdaTarget().readiness(self.ctx())}
|
|
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
|