apx-aws-lambda 1.0.0__tar.gz → 1.2.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-1.0.0 → apx_aws_lambda-1.2.0}/PKG-INFO +4 -4
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/README.md +2 -2
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/connect/template.yaml +4 -4
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/lambda_.py +15 -4
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/template.yaml +5 -0
- apx_aws_lambda-1.2.0/apx_aws_lambda/plugin.py +69 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda.egg-info/PKG-INFO +4 -4
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda.egg-info/requires.txt +1 -1
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/pyproject.toml +2 -2
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/tests/test_targets.py +24 -2
- apx_aws_lambda-1.0.0/apx_aws_lambda/plugin.py +0 -47
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/LICENSE +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/__init__.py +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/cli.py +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/cookiecutter.json +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/hooks/post_gen_project.py +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/.github/workflows/deploy.yml +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/DEPLOY.md +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/Makefile +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/policy.json +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/requirements/trust.json +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/cloud/aws/lambda/{{cookiecutter.project_slug}}/samconfig.toml +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/overlays/index.json +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/shell.py +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda/tools.py +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda.egg-info/SOURCES.txt +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda.egg-info/dependency_links.txt +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda.egg-info/entry_points.txt +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/apx_aws_lambda.egg-info/top_level.txt +0 -0
- {apx_aws_lambda-1.0.0 → apx_aws_lambda-1.2.0}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.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.32.0
|
|
11
11
|
Requires-Dist: awscli>=1.34
|
|
12
12
|
Requires-Dist: aws-sam-cli>=1.120
|
|
13
13
|
Provides-Extra: dev
|
|
@@ -77,13 +77,13 @@ The target looks for credentials in this order:
|
|
|
77
77
|
|
|
78
78
|
One CloudFormation stack, IAM only — no function, no table, nothing to upgrade. AWS itself trusts the platform's OIDC tokens; the token's session tag keeps each deploy inside its app.
|
|
79
79
|
|
|
80
|
-
**1. Create the stack** — once per AWS account, with your own AWS credentials (not the root account).
|
|
80
|
+
**1. Create the stack** — once per AWS account, with your own AWS credentials (not the root account). On the platform: Plugins → AWS Lambda → Configure → **Connect AWS** copies the command and opens AWS CloudShell (the AWS sign-in first); paste, press Enter, and paste the account ID it prints into the field. Or in the console: CloudFormation → Create stack → *Upload a template file* → [`apx_aws_lambda/connect/template.yaml`](apx_aws_lambda/connect/template.yaml), parameters `IssuerUrl` (the platform's public url) and `Organization` (its slug), acknowledge IAM; or from a machine:
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
83
|
action-platform aws-lambda connect https://platform.example.com acme # --region, --stack-name, --oidc-provider-arn
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
**2. Tell the platform** — Plugins → AWS Lambda → Configure → **
|
|
86
|
+
**2. Tell the platform** — Plugins → AWS Lambda → Configure → **AWS account ID** = the 12-digit account ID (or the stack's `DeployRoleArn` output). Every app of the organization whose `platform.toml` says `target = "aws/lambda"` deploys from then on; nothing to register per app.
|
|
87
87
|
|
|
88
88
|
What the stack creates:
|
|
89
89
|
|
|
@@ -59,13 +59,13 @@ The target looks for credentials in this order:
|
|
|
59
59
|
|
|
60
60
|
One CloudFormation stack, IAM only — no function, no table, nothing to upgrade. AWS itself trusts the platform's OIDC tokens; the token's session tag keeps each deploy inside its app.
|
|
61
61
|
|
|
62
|
-
**1. Create the stack** — once per AWS account, with your own AWS credentials (not the root account).
|
|
62
|
+
**1. Create the stack** — once per AWS account, with your own AWS credentials (not the root account). On the platform: Plugins → AWS Lambda → Configure → **Connect AWS** copies the command and opens AWS CloudShell (the AWS sign-in first); paste, press Enter, and paste the account ID it prints into the field. Or in the console: CloudFormation → Create stack → *Upload a template file* → [`apx_aws_lambda/connect/template.yaml`](apx_aws_lambda/connect/template.yaml), parameters `IssuerUrl` (the platform's public url) and `Organization` (its slug), acknowledge IAM; or from a machine:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
65
|
action-platform aws-lambda connect https://platform.example.com acme # --region, --stack-name, --oidc-provider-arn
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
**2. Tell the platform** — Plugins → AWS Lambda → Configure → **
|
|
68
|
+
**2. Tell the platform** — Plugins → AWS Lambda → Configure → **AWS account ID** = the 12-digit account ID (or the stack's `DeployRoleArn` output). Every app of the organization whose `platform.toml` says `target = "aws/lambda"` deploys from then on; nothing to register per app.
|
|
69
69
|
|
|
70
70
|
What the stack creates:
|
|
71
71
|
|
|
@@ -156,7 +156,7 @@ Resources:
|
|
|
156
156
|
Action:
|
|
157
157
|
- iam:CreateRole
|
|
158
158
|
- iam:PutRolePermissionsBoundary
|
|
159
|
-
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/${!aws:PrincipalTag/action-platform:prefix}
|
|
159
|
+
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/action-platform/${!aws:PrincipalTag/action-platform:prefix}/*"
|
|
160
160
|
Condition:
|
|
161
161
|
StringEquals:
|
|
162
162
|
iam:PermissionsBoundary: !Ref Boundary
|
|
@@ -165,7 +165,7 @@ Resources:
|
|
|
165
165
|
- Sid: TagExecutionRoleWithItsOwnPrefix
|
|
166
166
|
Effect: Allow
|
|
167
167
|
Action: iam:TagRole
|
|
168
|
-
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/${!aws:PrincipalTag/action-platform:prefix}
|
|
168
|
+
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/action-platform/${!aws:PrincipalTag/action-platform:prefix}/*"
|
|
169
169
|
Condition:
|
|
170
170
|
StringEqualsIfExists:
|
|
171
171
|
aws:RequestTag/action-platform:prefix: "${aws:PrincipalTag/action-platform:prefix}"
|
|
@@ -183,11 +183,11 @@ Resources:
|
|
|
183
183
|
- iam:DeleteRolePolicy
|
|
184
184
|
- iam:ListRolePolicies
|
|
185
185
|
- iam:ListAttachedRolePolicies
|
|
186
|
-
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/${!aws:PrincipalTag/action-platform:prefix}
|
|
186
|
+
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/action-platform/${!aws:PrincipalTag/action-platform:prefix}/*"
|
|
187
187
|
- Sid: PassExecutionRoleToLambda
|
|
188
188
|
Effect: Allow
|
|
189
189
|
Action: iam:PassRole
|
|
190
|
-
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/${!aws:PrincipalTag/action-platform:prefix}
|
|
190
|
+
Resource: !Sub "arn:aws:iam::${AWS::AccountId}:role/action-platform/${!aws:PrincipalTag/action-platform:prefix}/*"
|
|
191
191
|
Condition:
|
|
192
192
|
StringEquals:
|
|
193
193
|
iam:PassedToService: lambda.amazonaws.com
|
|
@@ -55,6 +55,11 @@ class LambdaTarget(DeployTarget):
|
|
|
55
55
|
if not role:
|
|
56
56
|
return None
|
|
57
57
|
|
|
58
|
+
if re.fullmatch(r"\d{12}", role.strip()):
|
|
59
|
+
role = (
|
|
60
|
+
f"arn:aws:iam::{role.strip()}:role/action-platform/ActionPlatformDeploy"
|
|
61
|
+
)
|
|
62
|
+
|
|
58
63
|
app = self.app or ctx.env.get("AP_APP") or os.environ.get("AP_APP", "")
|
|
59
64
|
parts = app.strip("/").split("/")
|
|
60
65
|
|
|
@@ -130,13 +135,14 @@ class LambdaTarget(DeployTarget):
|
|
|
130
135
|
own = [
|
|
131
136
|
item
|
|
132
137
|
for item in str(params.get("parameter_overrides") or "").split()
|
|
133
|
-
if not item.startswith(("Stage=", "PermissionsBoundaryArn="))
|
|
138
|
+
if not item.startswith(("Stage=", "PermissionsBoundaryArn=", "RolePath="))
|
|
134
139
|
]
|
|
135
140
|
own.append(f"Stage={ctx.stage}")
|
|
136
141
|
boundary = (env or {}).get("AP_BOUNDARY")
|
|
137
142
|
|
|
138
143
|
if boundary:
|
|
139
144
|
own.append(f"PermissionsBoundaryArn={boundary}")
|
|
145
|
+
own.append(f"RolePath={role_path((env or {})['AP_STACK_PREFIX'])}")
|
|
140
146
|
|
|
141
147
|
return ["--parameter-overrides", " ".join(own)]
|
|
142
148
|
|
|
@@ -253,7 +259,7 @@ class LambdaTarget(DeployTarget):
|
|
|
253
259
|
def _boundary_parameter(self, ctx: Context) -> Check:
|
|
254
260
|
text = (ctx.repo_root / "template.yaml").read_text(errors="replace")
|
|
255
261
|
|
|
256
|
-
if "PermissionsBoundaryArn" in text:
|
|
262
|
+
if "PermissionsBoundaryArn" in text and "RolePath" in text:
|
|
257
263
|
return Check(
|
|
258
264
|
"template.boundary", True, "the execution role takes the boundary"
|
|
259
265
|
)
|
|
@@ -261,7 +267,7 @@ class LambdaTarget(DeployTarget):
|
|
|
261
267
|
return Check(
|
|
262
268
|
"template.boundary",
|
|
263
269
|
False,
|
|
264
|
-
"template.yaml
|
|
270
|
+
"template.yaml lacks the PermissionsBoundaryArn or RolePath parameter: a connected account creates the execution role only within its boundary, under the app's path",
|
|
265
271
|
fix="apply the aws/lambda overlay again: action-platform cloud set aws/lambda",
|
|
266
272
|
)
|
|
267
273
|
|
|
@@ -332,7 +338,7 @@ class LambdaTarget(DeployTarget):
|
|
|
332
338
|
context: list[str] = []
|
|
333
339
|
|
|
334
340
|
if boundary:
|
|
335
|
-
execution = f"arn:aws:iam::{account}:role
|
|
341
|
+
execution = f"arn:aws:iam::{account}:role{role_path(env['AP_STACK_PREFIX'])}{stack}-ApiFunctionRole"
|
|
336
342
|
wanted.append((["iam:CreateRole", "iam:PassRole"], [execution]))
|
|
337
343
|
context = [
|
|
338
344
|
"--context-entries",
|
|
@@ -560,6 +566,11 @@ def _role_of(arn: str) -> str | None:
|
|
|
560
566
|
return f"arn:aws:iam::{found.group(1)}:role/{found.group(2)}" if found else None
|
|
561
567
|
|
|
562
568
|
|
|
569
|
+
def role_path(prefix: str) -> str:
|
|
570
|
+
"""Where a connected account keeps an app's execution roles: CloudFormation cuts a generated role name to 64 characters, which can drop the prefix from it, so the app's roles are told apart by their IAM path instead."""
|
|
571
|
+
return f"/action-platform/{prefix}/"
|
|
572
|
+
|
|
573
|
+
|
|
563
574
|
def connected_env(
|
|
564
575
|
ctx: Context, role_arn: str, prefix: str, session_name: str, region: str | None
|
|
565
576
|
) -> dict[str, str]:
|
|
@@ -18,6 +18,10 @@ Parameters:
|
|
|
18
18
|
Type: String
|
|
19
19
|
Default: ''
|
|
20
20
|
Description: The boundary the execution role SAM creates must carry (a connected account's ActionPlatformAppBoundary). Empty sets none.
|
|
21
|
+
RolePath:
|
|
22
|
+
Type: String
|
|
23
|
+
Default: /
|
|
24
|
+
Description: IAM path of the execution role SAM creates (a connected account's /action-platform/<prefix>/).
|
|
21
25
|
|
|
22
26
|
Conditions:
|
|
23
27
|
IsProd: !Equals [!Ref Stage, prod]
|
|
@@ -61,6 +65,7 @@ Resources:
|
|
|
61
65
|
{%- endif %}
|
|
62
66
|
{%- endif %}
|
|
63
67
|
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
|
|
68
|
+
RolePath: !Ref RolePath
|
|
64
69
|
Layers:
|
|
65
70
|
- !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:25
|
|
66
71
|
Environment:
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""The plugin: the aws/lambda overlay, `action-platform aws-lambda` commands, `aws_lambda_*` tools."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from action_platform.abc import Option, Plugin, Surface
|
|
9
|
+
|
|
10
|
+
from apx_aws_lambda import cli
|
|
11
|
+
from apx_aws_lambda.tools import register_tools
|
|
12
|
+
|
|
13
|
+
CLOUDSHELL = "https://console.aws.amazon.com/cloudshell/home?region=us-east-1"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def connect_command() -> str:
|
|
17
|
+
"""What the user pastes in CloudShell: the connect stack from this release's template on GitHub, then the account ID the platform asks for."""
|
|
18
|
+
try:
|
|
19
|
+
ref = f"v{version('apx-aws-lambda')}"
|
|
20
|
+
except PackageNotFoundError:
|
|
21
|
+
ref = "master"
|
|
22
|
+
|
|
23
|
+
template = f"https://raw.githubusercontent.com/actionplatform/apx-aws-lambda/{ref}/apx_aws_lambda/connect/template.yaml"
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
f"curl -fsSL {template} -o ap-connect.yaml"
|
|
27
|
+
" && aws cloudformation deploy --region us-east-1"
|
|
28
|
+
" --stack-name action-platform-connect --template-file ap-connect.yaml"
|
|
29
|
+
" --capabilities CAPABILITY_NAMED_IAM --no-fail-on-empty-changeset"
|
|
30
|
+
" --parameter-overrides IssuerUrl={issuer} Organization={organization}"
|
|
31
|
+
" && aws sts get-caller-identity --query Account --output text"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AwsLambdaPlugin(Plugin):
|
|
36
|
+
slug = "aws-lambda"
|
|
37
|
+
name = "AWS Lambda"
|
|
38
|
+
description = (
|
|
39
|
+
"Deploy to AWS Lambda with SAM; read CloudFormation stacks and functions"
|
|
40
|
+
)
|
|
41
|
+
min_core = "0.32.0"
|
|
42
|
+
needs = [
|
|
43
|
+
"tool: aws, sam (bundled as Python packages when not on PATH)",
|
|
44
|
+
"env: AWS_REGION; credentials from role_arn (the connected account's deploy role, OIDC, no keys) or the AWS CLI chain (SSO, profile, instance role)",
|
|
45
|
+
"net: *.amazonaws.com",
|
|
46
|
+
]
|
|
47
|
+
options = [
|
|
48
|
+
Option(
|
|
49
|
+
"role_arn",
|
|
50
|
+
"AWS account ID",
|
|
51
|
+
"text",
|
|
52
|
+
help="Paste the account ID the command prints.",
|
|
53
|
+
required=True,
|
|
54
|
+
action_label="Connect AWS",
|
|
55
|
+
action_url=CLOUDSHELL,
|
|
56
|
+
action_copy=connect_command(),
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def overlays(self) -> Path:
|
|
62
|
+
return Path(__file__).parent / "overlays"
|
|
63
|
+
|
|
64
|
+
def register(self, surface: Surface) -> None:
|
|
65
|
+
if surface.mcp is not None:
|
|
66
|
+
register_tools(surface.mcp)
|
|
67
|
+
|
|
68
|
+
if surface.cli is not None:
|
|
69
|
+
surface.cli.add_typer(cli.app, name="aws-lambda")
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apx-aws-lambda
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.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.32.0
|
|
11
11
|
Requires-Dist: awscli>=1.34
|
|
12
12
|
Requires-Dist: aws-sam-cli>=1.120
|
|
13
13
|
Provides-Extra: dev
|
|
@@ -77,13 +77,13 @@ The target looks for credentials in this order:
|
|
|
77
77
|
|
|
78
78
|
One CloudFormation stack, IAM only — no function, no table, nothing to upgrade. AWS itself trusts the platform's OIDC tokens; the token's session tag keeps each deploy inside its app.
|
|
79
79
|
|
|
80
|
-
**1. Create the stack** — once per AWS account, with your own AWS credentials (not the root account).
|
|
80
|
+
**1. Create the stack** — once per AWS account, with your own AWS credentials (not the root account). On the platform: Plugins → AWS Lambda → Configure → **Connect AWS** copies the command and opens AWS CloudShell (the AWS sign-in first); paste, press Enter, and paste the account ID it prints into the field. Or in the console: CloudFormation → Create stack → *Upload a template file* → [`apx_aws_lambda/connect/template.yaml`](apx_aws_lambda/connect/template.yaml), parameters `IssuerUrl` (the platform's public url) and `Organization` (its slug), acknowledge IAM; or from a machine:
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
83
|
action-platform aws-lambda connect https://platform.example.com acme # --region, --stack-name, --oidc-provider-arn
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
**2. Tell the platform** — Plugins → AWS Lambda → Configure → **
|
|
86
|
+
**2. Tell the platform** — Plugins → AWS Lambda → Configure → **AWS account ID** = the 12-digit account ID (or the stack's `DeployRoleArn` output). Every app of the organization whose `platform.toml` says `target = "aws/lambda"` deploys from then on; nothing to register per app.
|
|
87
87
|
|
|
88
88
|
What the stack creates:
|
|
89
89
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "apx-aws-lambda"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.2.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.32.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]"]
|
|
@@ -9,7 +9,7 @@ from unittest import mock
|
|
|
9
9
|
|
|
10
10
|
from action_platform.core.context import Context
|
|
11
11
|
from action_platform.core.exception import DeployError
|
|
12
|
-
from action_platform.core.scaffold.
|
|
12
|
+
from action_platform.core.scaffold.catalog import Matrix, with_plugin_clouds
|
|
13
13
|
from action_platform.plugins import Loaded, Plugins, PluginState, registry
|
|
14
14
|
|
|
15
15
|
from apx_aws_lambda import AwsLambdaPlugin, shell
|
|
@@ -373,6 +373,7 @@ class ConnectedAccountTest(unittest.TestCase):
|
|
|
373
373
|
)
|
|
374
374
|
(self.root / "template.yaml").write_text(
|
|
375
375
|
"Parameters:\n PermissionsBoundaryArn:\n Type: String\n"
|
|
376
|
+
" RolePath:\n Type: String\n"
|
|
376
377
|
)
|
|
377
378
|
self.calls: list[list[str]] = []
|
|
378
379
|
self.addCleanup(self.tmp.cleanup)
|
|
@@ -441,7 +442,8 @@ class ConnectedAccountTest(unittest.TestCase):
|
|
|
441
442
|
)
|
|
442
443
|
self.assertEqual(
|
|
443
444
|
deploy[deploy.index("--parameter-overrides") + 1],
|
|
444
|
-
f"DomainName= Stage=dev PermissionsBoundaryArn={self.BOUNDARY}"
|
|
445
|
+
f"DomainName= Stage=dev PermissionsBoundaryArn={self.BOUNDARY}"
|
|
446
|
+
" RolePath=/action-platform/ap-acme-shop-orders/",
|
|
445
447
|
)
|
|
446
448
|
self.assertEqual(
|
|
447
449
|
deploy[deploy.index("--tags") + 1],
|
|
@@ -478,6 +480,26 @@ class ConnectedAccountTest(unittest.TestCase):
|
|
|
478
480
|
|
|
479
481
|
self.assertFalse(checks["template.boundary"].ok)
|
|
480
482
|
|
|
483
|
+
def test_an_account_id_names_the_connect_stacks_role(self):
|
|
484
|
+
ctx = self.ctx()
|
|
485
|
+
ctx.env["AP_AWS_LAMBDA_ROLE_ARN"] = "123456789012"
|
|
486
|
+
|
|
487
|
+
self.assertEqual(
|
|
488
|
+
LambdaTarget().connected(ctx), (self.ROLE, "ap-acme-shop-orders")
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
def test_the_connect_command_fills_in_the_platform_and_the_organization(self):
|
|
492
|
+
from apx_aws_lambda.plugin import AwsLambdaPlugin
|
|
493
|
+
|
|
494
|
+
option = AwsLambdaPlugin.options[0]
|
|
495
|
+
|
|
496
|
+
self.assertIn("cloudshell", option.action_url)
|
|
497
|
+
self.assertIn("aws cloudformation deploy", option.action_copy)
|
|
498
|
+
self.assertIn(
|
|
499
|
+
"IssuerUrl={issuer} Organization={organization}", option.action_copy
|
|
500
|
+
)
|
|
501
|
+
self.assertIn("connect/template.yaml", option.action_copy)
|
|
502
|
+
|
|
481
503
|
def test_a_role_of_the_repository_wins_over_the_connected_account(self):
|
|
482
504
|
target = LambdaTarget(role_arn="arn:aws:iam::1:role/own")
|
|
483
505
|
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"""The plugin: the aws/lambda overlay, `action-platform aws-lambda` commands, `aws_lambda_*` tools."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
from action_platform.abc import Option, Plugin, Surface
|
|
8
|
-
|
|
9
|
-
from apx_aws_lambda import cli
|
|
10
|
-
from apx_aws_lambda.tools import register_tools
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class AwsLambdaPlugin(Plugin):
|
|
14
|
-
slug = "aws-lambda"
|
|
15
|
-
name = "AWS Lambda"
|
|
16
|
-
description = (
|
|
17
|
-
"Deploy to AWS Lambda with SAM; read CloudFormation stacks and functions"
|
|
18
|
-
)
|
|
19
|
-
min_core = "0.17.9"
|
|
20
|
-
needs = [
|
|
21
|
-
"tool: aws, sam (bundled as Python packages when not on PATH)",
|
|
22
|
-
"env: AWS_REGION; credentials from role_arn (the connected account's deploy role, OIDC, no keys) or the AWS CLI chain (SSO, profile, instance role)",
|
|
23
|
-
"net: *.amazonaws.com",
|
|
24
|
-
]
|
|
25
|
-
options = [
|
|
26
|
-
Option(
|
|
27
|
-
"role_arn",
|
|
28
|
-
"Deploy role ARN",
|
|
29
|
-
"text",
|
|
30
|
-
help=(
|
|
31
|
-
"The deploy role of your connected AWS account: the platform's token assumes it, and the token's session tag keeps every deploy inside its app, so the platform never holds an access key and nothing runs in your account. "
|
|
32
|
-
"Create it once with the IAM-only stack apx_aws_lambda/connect/template.yaml (CloudFormation console, Upload a template file) or `action-platform aws-lambda connect <platform url> <organization>`; the DeployRoleArn output goes here."
|
|
33
|
-
),
|
|
34
|
-
required=True,
|
|
35
|
-
),
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
@property
|
|
39
|
-
def overlays(self) -> Path:
|
|
40
|
-
return Path(__file__).parent / "overlays"
|
|
41
|
-
|
|
42
|
-
def register(self, surface: Surface) -> None:
|
|
43
|
-
if surface.mcp is not None:
|
|
44
|
-
register_tools(surface.mcp)
|
|
45
|
-
|
|
46
|
-
if surface.cli is not None:
|
|
47
|
-
surface.cli.add_typer(cli.app, name="aws-lambda")
|
|
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
|