apx-aws-lambda 0.3.5__tar.gz → 0.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/PKG-INFO +2 -2
  2. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/README.md +1 -1
  3. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/lambda_.py +9 -8
  4. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda.egg-info/PKG-INFO +2 -2
  5. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/pyproject.toml +1 -1
  6. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/tests/test_proxy.py +14 -7
  7. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/tests/test_targets.py +2 -0
  8. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/LICENSE +0 -0
  9. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/__init__.py +0 -0
  10. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/cli.py +0 -0
  11. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
  12. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
  13. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
  14. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
  15. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/Makefile +0 -0
  16. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/lambda_handler.py +0 -0
  17. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/_lang/python/tools/lambda_requirements.py +0 -0
  18. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
  19. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
  20. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
  21. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml +0 -0
  22. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/overlays/index.json +0 -0
  23. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/plugin.py +0 -0
  24. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/proxy.py +0 -0
  25. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/shell.py +0 -0
  26. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda/tools.py +0 -0
  27. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda.egg-info/SOURCES.txt +0 -0
  28. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
  29. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
  30. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda.egg-info/requires.txt +0 -0
  31. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/apx_aws_lambda.egg-info/top_level.txt +0 -0
  32. {apx_aws_lambda-0.3.5 → apx_aws_lambda-0.3.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.5
3
+ Version: 0.3.6
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
@@ -110,7 +110,7 @@ proxy_url = "https://xxxx.lambda-url.us-east-1.on.aws"
110
110
  app = "acme/shop/orders"
111
111
  ```
112
112
 
113
- `stack_name` in `samconfig.toml` must start with `ap-acme-shop-orders` — the deploy role reaches those stacks only, and the target refuses anything else before touching AWS.
113
+ Through the proxy the stack is named `ap-acme-shop-orders-dev` / `-prod` — the deploy role reaches that prefix only, so the target sets `--stack-name` itself and `stack_name` in `samconfig.toml` is ignored; the repository never has to know the organization.
114
114
 
115
115
  **4.** `action-platform deploy`.
116
116
 
@@ -90,7 +90,7 @@ proxy_url = "https://xxxx.lambda-url.us-east-1.on.aws"
90
90
  app = "acme/shop/orders"
91
91
  ```
92
92
 
93
- `stack_name` in `samconfig.toml` must start with `ap-acme-shop-orders` — the deploy role reaches those stacks only, and the target refuses anything else before touching AWS.
93
+ Through the proxy the stack is named `ap-acme-shop-orders-dev` / `-prod` — the deploy role reaches that prefix only, so the target sets `--stack-name` itself and `stack_name` in `samconfig.toml` is ignored; the repository never has to know the organization.
94
94
 
95
95
  **4.** `action-platform deploy`.
96
96
 
@@ -89,6 +89,12 @@ class LambdaTarget(DeployTarget):
89
89
  return tomllib.loads(path.read_text())
90
90
 
91
91
  def _stack(self, ctx: Context) -> str:
92
+ """The stack: `<prefix>-<stage>` when the proxy granted a prefix — the repository's samconfig.toml never has to know the organization — else samconfig.toml's `stack_name`."""
93
+ prefix = (self.env(ctx) or {}).get("AP_STACK_PREFIX")
94
+
95
+ if prefix:
96
+ return f"{prefix}-{'prod' if ctx.stage == 'prod' else 'dev'}"
97
+
92
98
  params = (
93
99
  self._samconfig(ctx)
94
100
  .get(self._stage(ctx), {})
@@ -138,15 +144,8 @@ class LambdaTarget(DeployTarget):
138
144
  "template.yaml not found: apply the aws/lambda overlay first"
139
145
  )
140
146
 
141
- stack = self._stack(ctx)
147
+ self._stack(ctx)
142
148
  env = self.env(ctx)
143
- prefix = (env or {}).get("AP_STACK_PREFIX")
144
-
145
- if prefix and not stack.startswith(prefix):
146
- raise DeployError(
147
- f"stack_name {stack!r} must start with {prefix!r}: the proxy grants deploy on that prefix only"
148
- )
149
-
150
149
  shell.aws("sts", "get-caller-identity", region=self._region(ctx), env=env)
151
150
  shell.run(
152
151
  [*shell.require("sam", ""), "validate", "--lint"],
@@ -164,6 +163,8 @@ class LambdaTarget(DeployTarget):
164
163
  "deploy",
165
164
  "--no-confirm-changeset",
166
165
  "--no-fail-on-empty-changeset",
166
+ "--stack-name",
167
+ self._stack(ctx),
167
168
  ]
168
169
 
169
170
  if stage != "default":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apx-aws-lambda
3
- Version: 0.3.5
3
+ Version: 0.3.6
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
@@ -110,7 +110,7 @@ proxy_url = "https://xxxx.lambda-url.us-east-1.on.aws"
110
110
  app = "acme/shop/orders"
111
111
  ```
112
112
 
113
- `stack_name` in `samconfig.toml` must start with `ap-acme-shop-orders` — the deploy role reaches those stacks only, and the target refuses anything else before touching AWS.
113
+ Through the proxy the stack is named `ap-acme-shop-orders-dev` / `-prod` — the deploy role reaches that prefix only, so the target sets `--stack-name` itself and `stack_name` in `samconfig.toml` is ignored; the repository never has to know the organization.
114
114
 
115
115
  **4.** `action-platform deploy`.
116
116
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "apx-aws-lambda"
3
- version = "0.3.5"
3
+ version = "0.3.6"
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"
@@ -207,24 +207,31 @@ class ProxyClientTest(unittest.TestCase):
207
207
  with self.assertRaises(DeployError):
208
208
  ProxyClient("https://proxy.test", "orders")
209
209
 
210
- def test_the_target_refuses_a_stack_outside_the_prefix(self):
210
+ def test_the_stack_follows_the_prefix_the_proxy_granted(self):
211
211
  (self.root / "samconfig.toml").write_text(SAMCONFIG.format(stack="shop-dev"))
212
212
  (self.root / "template.yaml").write_text("Resources: {}\n")
213
213
  fake = FakeProxy({"POST /apps/acme/shop/orders/credentials": GRANTED})
214
214
  target = LambdaTarget(proxy_url="https://proxy.test", app="acme/shop/orders")
215
+ calls: list[list[str]] = []
216
+
217
+ def run(args, cwd=None, env=None):
218
+ calls.append(args)
219
+
220
+ return "{}"
215
221
 
216
222
  with (
217
223
  mock.patch("urllib.request.urlopen", fake),
218
224
  mock.patch.multiple(
219
- shell,
220
- run=lambda *a, **k: "{}",
221
- require=lambda tool, hint: [f"/usr/bin/{tool}"],
225
+ shell, run=run, require=lambda tool, hint: [f"/usr/bin/{tool}"]
222
226
  ),
223
227
  ):
224
- with self.assertRaises(DeployError) as caught:
225
- target.preflight(self.ctx())
228
+ target.preflight(self.ctx())
229
+ target.deploy(self.ctx())
226
230
 
227
- self.assertIn("must start with 'ap-acme-shop-orders'", str(caught.exception))
231
+ deploy = next(c for c in calls if c[1] == "deploy")
232
+ self.assertEqual(
233
+ deploy[deploy.index("--stack-name") + 1], "ap-acme-shop-orders-dev"
234
+ )
228
235
 
229
236
  def test_the_target_deploys_with_the_granted_credentials(self):
230
237
  (self.root / "samconfig.toml").write_text(
@@ -79,6 +79,8 @@ class LambdaTargetTest(unittest.TestCase):
79
79
  "deploy",
80
80
  "--no-confirm-changeset",
81
81
  "--no-fail-on-empty-changeset",
82
+ "--stack-name",
83
+ "shop-prod",
82
84
  "--config-env",
83
85
  "prod",
84
86
  ],
File without changes
File without changes