apx-aws-amplify 1.0.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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may accept a fee in exchange for,
167
+ acceptance of support, warranty, indemnity, or other liability
168
+ obligations and/or rights consistent with this License. However, in
169
+ accepting such obligations, You may act only on Your own behalf
170
+ and on Your sole responsibility, not on behalf of any other
171
+ Contributor, and only if You agree to indemnify, defend, and hold
172
+ each Contributor harmless for any liability incurred by, or claims
173
+ asserted against, such Contributor by reason of your accepting any
174
+ such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same page as the copyright notice for easier identification within
187
+ the file itself.
188
+
189
+ Copyright 2026 Fernando Celmer
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: apx-aws-amplify
3
+ Version: 1.0.0
4
+ Summary: AWS Amplify Hosting for Action Platform: the aws/amplify deploy target, built on the platform and published as a manual deployment per scope.
5
+ Author-email: Action Platform <cloud@actionplatform.io>
6
+ License-Expression: Apache-2.0
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: action-platform>=0.53.0
11
+ Requires-Dist: apx-aws-lambda>=1.8.0
12
+ Requires-Dist: pyyaml>=6
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8; extra == "dev"
15
+ Requires-Dist: ruff>=0.6; extra == "dev"
16
+ Dynamic: license-file
17
+
18
+ # apx-aws-amplify
19
+
20
+ AWS Amplify Hosting for [Action Platform](https://github.com/actionplatform/action-platform): the `aws/amplify` deploy target.
21
+
22
+ The platform builds the release itself and publishes it as an Amplify manual deployment, one Amplify app per platform app and one branch per scope. Amplify never connects to the repository and never builds it; no access key is stored anywhere.
23
+
24
+ ## Contents
25
+
26
+ - [What it does](#what-it-does)
27
+ - [Install](#install)
28
+ - [Connect the AWS account](#connect-the-aws-account)
29
+ - [The repository](#the-repository)
30
+ - [Deploy](#deploy)
31
+ - [Readiness](#readiness)
32
+ - [Rollback, diagnose, delete](#rollback-diagnose-delete)
33
+ - [Options](#options)
34
+ - [Limits](#limits)
35
+ - [Development](#development)
36
+
37
+ ## What it does
38
+
39
+ | Step | What happens |
40
+ |---|---|
41
+ | build | `amplify.yml`'s `preBuild` and `build` commands run in one shell (`set -e`) where the deploy runs, at the release tag. `nvm use` is skipped: the worker's Node is used. The build gets no AWS credentials and none of the platform's connection options |
42
+ | package | the files under `artifacts.baseDirectory` that match `artifacts.files` are zipped |
43
+ | publish | `CreateDeployment`, the zip uploaded to the url Amplify returns, `StartDeployment` |
44
+ | verify | the job is followed until it is `SUCCEED`, then `https://<scope>.<app id>.amplifyapp.com` + `health` has to answer 2xx (retried for a minute) |
45
+ | record | the branch's description keeps the last 10 versions deployed there, newest first; rollback reads it |
46
+
47
+ ## Install
48
+
49
+ On the platform: Admin → Plugins → install `aws-amplify`. On a machine:
50
+
51
+ ```bash
52
+ action-platform plugin install aws-amplify
53
+ ```
54
+
55
+ It depends on [apx-aws-lambda](https://github.com/actionplatform/apx-aws-lambda) 1.8.0 or later, whose connect stack and credentials it reuses.
56
+
57
+ ## Connect the AWS account
58
+
59
+ The account is the one the apx-aws-lambda connect stack connects: Connect → Deploy → AWS Amplify → Configure → **Connect AWS** runs the same command, and **AWS account ID** takes the same 12 digits. An organization that already connected AWS Lambda pastes the same ID; the target also falls back to the AWS Lambda connection when the AWS Amplify one is empty.
60
+
61
+ The connect stack must be `TemplateVersion` 3 or later (apx-aws-lambda 1.8.0): that version lets the deploy role create Amplify apps and branches tagged with the app's `action-platform:prefix` and run their deployments. An older stack fails the `aws.permissions` check; run **Connect AWS** again to update it.
62
+
63
+ Credentials, in order:
64
+
65
+ 1. `role_arn` under `[deploy]`: that role, assumed with the platform's OIDC token.
66
+ 2. The organization's connected account (`AP_AWS_AMPLIFY_ROLE_ARN`, else `AP_AWS_LAMBDA_ROLE_ARN`, with `AP_APP`): the connect stack's deploy role, scoped to the app by the token's session tag.
67
+ 3. Neither: the AWS CLI's own chain (profile, SSO, instance role).
68
+
69
+ ## The repository
70
+
71
+ Apply the `aws/amplify` overlay (Configuration → Deploy target, or `action-platform cloud set aws/amplify`). It brings `amplify.yml` and `customHttp.yml`; the target reads `amplify.yml` from the release tag:
72
+
73
+ ```yaml
74
+ version: 1
75
+ frontend:
76
+ phases:
77
+ preBuild:
78
+ commands:
79
+ - npm ci
80
+ build:
81
+ commands:
82
+ - npm run build
83
+ artifacts:
84
+ baseDirectory: build
85
+ files:
86
+ - '**/*'
87
+ ```
88
+
89
+ `platform.toml`:
90
+
91
+ ```toml
92
+ [deploy]
93
+ target = "aws/amplify"
94
+ ```
95
+
96
+ ## Deploy
97
+
98
+ A deploy of release `v1.2.0` to scope `test` of `acme/shop/web` on a connected account:
99
+
100
+ - Amplify app `ap-acme-shop-web` (platform `WEB`, tag `action-platform:prefix=ap-acme-shop-web`), created on the first deploy.
101
+ - Branch `test` (stage `DEVELOPMENT`; `PRODUCTION` for scope `prod`), created on the first deploy to that scope, tagged the same.
102
+ - The build, the zip and the manual deployment above. The deploy fails when a job is already running on the branch, when the job ends `FAILED` or `CANCELLED` (the failed step's reason is the error), or when the url does not answer.
103
+ - Result url: `https://test.<app id>.amplifyapp.com`.
104
+
105
+ ## Readiness
106
+
107
+ | Check | Fails when |
108
+ |---|---|
109
+ | `overlay.buildspec` | `amplify.yml` is missing at the release, is not valid YAML, or has no `frontend.artifacts.baseDirectory` |
110
+ | `overlay.static` | `package.json` depends on a Node HTTP server (express, fastify, koa, hapi, nest, hono): Amplify serves a manual deployment as static files only, so the app never runs there |
111
+ | `build.tools` | a command the build runs is not installed where the deploy runs |
112
+ | `aws.credentials` | the deploy role cannot be assumed |
113
+ | `aws.permissions` | the deploy role, simulated with the app's prefix as principal, request and resource tag, may not create the app or branch or run a deployment |
114
+ | `amplify.branch` | Amplify cannot be read, or a job is running on the scope's branch |
115
+
116
+ ## Rollback, diagnose, delete
117
+
118
+ - **Rollback** without a version builds the previous version recorded on the branch again from its git tag (same shape as the release tag: `v1.1.0`, `web/v1.1.0`) and publishes it; with a version, that one. It needs the repository's git history where the rollback runs, and fails with the reason when the tag cannot be read. Amplify keeps no earlier manual deployment to switch back to.
119
+ - **Diagnose**: the branch's last job status, the version deployed, the url.
120
+ - **Delete**: the scope's branch; the app too once no branch is left.
121
+
122
+ ## Options
123
+
124
+ | `[deploy]` key | Default | |
125
+ |---|---|---|
126
+ | `region` | `AWS_REGION`, else `us-east-1` | |
127
+ | `role_arn` | | a role of your own instead of the connected account |
128
+ | `name` | the app's prefix | the Amplify app's name without a connected account |
129
+ | `buildspec` | `amplify.yml` | |
130
+ | `health` | `/` | path asked after the deploy; empty skips it |
131
+ | `session_name` | `action-platform` | |
132
+
133
+ ## Limits
134
+
135
+ - Static builds only. Manual deployments do not run server-side code, whatever the app's platform (`WEB_COMPUTE` included); an Express or other Node server belongs on `aws/lambda` or `docker`.
136
+ - AWS has no tag condition for Amplify deployments and jobs: the connect stack allows `CreateDeployment`, `StartDeployment`, `ListJobs` and `GetJob` on any branch of the account, while apps and branches are scoped by the prefix tag.
137
+ - One frontend per repository: an `amplify.yml` with `applications` (a monorepo) is refused.
138
+
139
+ ## Development
140
+
141
+ ```bash
142
+ pip install -e ".[dev]"
143
+ ruff check . && ruff format --check .
144
+ pytest -q
145
+ ```
146
+
147
+ Releases: `action-platform release minor|patch` tags `vX.Y.Z`; the GitHub release publishes to PyPI.
@@ -0,0 +1,130 @@
1
+ # apx-aws-amplify
2
+
3
+ AWS Amplify Hosting for [Action Platform](https://github.com/actionplatform/action-platform): the `aws/amplify` deploy target.
4
+
5
+ The platform builds the release itself and publishes it as an Amplify manual deployment, one Amplify app per platform app and one branch per scope. Amplify never connects to the repository and never builds it; no access key is stored anywhere.
6
+
7
+ ## Contents
8
+
9
+ - [What it does](#what-it-does)
10
+ - [Install](#install)
11
+ - [Connect the AWS account](#connect-the-aws-account)
12
+ - [The repository](#the-repository)
13
+ - [Deploy](#deploy)
14
+ - [Readiness](#readiness)
15
+ - [Rollback, diagnose, delete](#rollback-diagnose-delete)
16
+ - [Options](#options)
17
+ - [Limits](#limits)
18
+ - [Development](#development)
19
+
20
+ ## What it does
21
+
22
+ | Step | What happens |
23
+ |---|---|
24
+ | build | `amplify.yml`'s `preBuild` and `build` commands run in one shell (`set -e`) where the deploy runs, at the release tag. `nvm use` is skipped: the worker's Node is used. The build gets no AWS credentials and none of the platform's connection options |
25
+ | package | the files under `artifacts.baseDirectory` that match `artifacts.files` are zipped |
26
+ | publish | `CreateDeployment`, the zip uploaded to the url Amplify returns, `StartDeployment` |
27
+ | verify | the job is followed until it is `SUCCEED`, then `https://<scope>.<app id>.amplifyapp.com` + `health` has to answer 2xx (retried for a minute) |
28
+ | record | the branch's description keeps the last 10 versions deployed there, newest first; rollback reads it |
29
+
30
+ ## Install
31
+
32
+ On the platform: Admin → Plugins → install `aws-amplify`. On a machine:
33
+
34
+ ```bash
35
+ action-platform plugin install aws-amplify
36
+ ```
37
+
38
+ It depends on [apx-aws-lambda](https://github.com/actionplatform/apx-aws-lambda) 1.8.0 or later, whose connect stack and credentials it reuses.
39
+
40
+ ## Connect the AWS account
41
+
42
+ The account is the one the apx-aws-lambda connect stack connects: Connect → Deploy → AWS Amplify → Configure → **Connect AWS** runs the same command, and **AWS account ID** takes the same 12 digits. An organization that already connected AWS Lambda pastes the same ID; the target also falls back to the AWS Lambda connection when the AWS Amplify one is empty.
43
+
44
+ The connect stack must be `TemplateVersion` 3 or later (apx-aws-lambda 1.8.0): that version lets the deploy role create Amplify apps and branches tagged with the app's `action-platform:prefix` and run their deployments. An older stack fails the `aws.permissions` check; run **Connect AWS** again to update it.
45
+
46
+ Credentials, in order:
47
+
48
+ 1. `role_arn` under `[deploy]`: that role, assumed with the platform's OIDC token.
49
+ 2. The organization's connected account (`AP_AWS_AMPLIFY_ROLE_ARN`, else `AP_AWS_LAMBDA_ROLE_ARN`, with `AP_APP`): the connect stack's deploy role, scoped to the app by the token's session tag.
50
+ 3. Neither: the AWS CLI's own chain (profile, SSO, instance role).
51
+
52
+ ## The repository
53
+
54
+ Apply the `aws/amplify` overlay (Configuration → Deploy target, or `action-platform cloud set aws/amplify`). It brings `amplify.yml` and `customHttp.yml`; the target reads `amplify.yml` from the release tag:
55
+
56
+ ```yaml
57
+ version: 1
58
+ frontend:
59
+ phases:
60
+ preBuild:
61
+ commands:
62
+ - npm ci
63
+ build:
64
+ commands:
65
+ - npm run build
66
+ artifacts:
67
+ baseDirectory: build
68
+ files:
69
+ - '**/*'
70
+ ```
71
+
72
+ `platform.toml`:
73
+
74
+ ```toml
75
+ [deploy]
76
+ target = "aws/amplify"
77
+ ```
78
+
79
+ ## Deploy
80
+
81
+ A deploy of release `v1.2.0` to scope `test` of `acme/shop/web` on a connected account:
82
+
83
+ - Amplify app `ap-acme-shop-web` (platform `WEB`, tag `action-platform:prefix=ap-acme-shop-web`), created on the first deploy.
84
+ - Branch `test` (stage `DEVELOPMENT`; `PRODUCTION` for scope `prod`), created on the first deploy to that scope, tagged the same.
85
+ - The build, the zip and the manual deployment above. The deploy fails when a job is already running on the branch, when the job ends `FAILED` or `CANCELLED` (the failed step's reason is the error), or when the url does not answer.
86
+ - Result url: `https://test.<app id>.amplifyapp.com`.
87
+
88
+ ## Readiness
89
+
90
+ | Check | Fails when |
91
+ |---|---|
92
+ | `overlay.buildspec` | `amplify.yml` is missing at the release, is not valid YAML, or has no `frontend.artifacts.baseDirectory` |
93
+ | `overlay.static` | `package.json` depends on a Node HTTP server (express, fastify, koa, hapi, nest, hono): Amplify serves a manual deployment as static files only, so the app never runs there |
94
+ | `build.tools` | a command the build runs is not installed where the deploy runs |
95
+ | `aws.credentials` | the deploy role cannot be assumed |
96
+ | `aws.permissions` | the deploy role, simulated with the app's prefix as principal, request and resource tag, may not create the app or branch or run a deployment |
97
+ | `amplify.branch` | Amplify cannot be read, or a job is running on the scope's branch |
98
+
99
+ ## Rollback, diagnose, delete
100
+
101
+ - **Rollback** without a version builds the previous version recorded on the branch again from its git tag (same shape as the release tag: `v1.1.0`, `web/v1.1.0`) and publishes it; with a version, that one. It needs the repository's git history where the rollback runs, and fails with the reason when the tag cannot be read. Amplify keeps no earlier manual deployment to switch back to.
102
+ - **Diagnose**: the branch's last job status, the version deployed, the url.
103
+ - **Delete**: the scope's branch; the app too once no branch is left.
104
+
105
+ ## Options
106
+
107
+ | `[deploy]` key | Default | |
108
+ |---|---|---|
109
+ | `region` | `AWS_REGION`, else `us-east-1` | |
110
+ | `role_arn` | | a role of your own instead of the connected account |
111
+ | `name` | the app's prefix | the Amplify app's name without a connected account |
112
+ | `buildspec` | `amplify.yml` | |
113
+ | `health` | `/` | path asked after the deploy; empty skips it |
114
+ | `session_name` | `action-platform` | |
115
+
116
+ ## Limits
117
+
118
+ - Static builds only. Manual deployments do not run server-side code, whatever the app's platform (`WEB_COMPUTE` included); an Express or other Node server belongs on `aws/lambda` or `docker`.
119
+ - AWS has no tag condition for Amplify deployments and jobs: the connect stack allows `CreateDeployment`, `StartDeployment`, `ListJobs` and `GetJob` on any branch of the account, while apps and branches are scoped by the prefix tag.
120
+ - One frontend per repository: an `amplify.yml` with `applications` (a monorepo) is refused.
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ pip install -e ".[dev]"
126
+ ruff check . && ruff format --check .
127
+ pytest -q
128
+ ```
129
+
130
+ Releases: `action-platform release minor|patch` tags `vX.Y.Z`; the GitHub release publishes to PyPI.
@@ -0,0 +1,5 @@
1
+ """AWS Amplify Hosting for Action Platform: `aws/amplify` as a deploy target."""
2
+
3
+ from apx_aws_amplify.plugin import AwsAmplifyPlugin
4
+
5
+ __all__ = ["AwsAmplifyPlugin"]
@@ -0,0 +1,152 @@
1
+ """The overlay's `amplify.yml`, run on the platform instead of in Amplify's own build: its preBuild and build commands in one shell, then its artifacts zipped for a manual deployment."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import fnmatch
6
+ import io
7
+ import json
8
+ import os
9
+ import shutil
10
+ import zipfile
11
+ from dataclasses import dataclass
12
+ from pathlib import Path
13
+
14
+ import yaml
15
+ from action_platform.core.exception import DeployError
16
+ from action_platform.core.process import stream
17
+ from action_platform.runtime.logging import emit
18
+
19
+ SKIPPED = ("nvm ",)
20
+ SERVERS = ("express", "fastify", "koa", "@hapi/hapi", "@nestjs/core", "hono")
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class Buildspec:
25
+ commands: list[str]
26
+ base: str
27
+ files: list[str]
28
+
29
+ @classmethod
30
+ def parse(cls, text: str) -> Buildspec:
31
+ try:
32
+ data = yaml.safe_load(text) or {}
33
+ except yaml.YAMLError as e:
34
+ raise DeployError(f"amplify.yml is not valid YAML: {e}") from e
35
+
36
+ if not isinstance(data, dict):
37
+ raise DeployError("amplify.yml is not a mapping")
38
+
39
+ frontend = data.get("frontend") or {}
40
+
41
+ if not frontend and data.get("applications"):
42
+ raise DeployError(
43
+ "amplify.yml declares applications (a monorepo); aws/amplify builds a single frontend"
44
+ )
45
+
46
+ phases = frontend.get("phases") or {}
47
+ commands = [
48
+ str(c)
49
+ for phase in ("preBuild", "build")
50
+ for c in ((phases.get(phase) or {}).get("commands") or [])
51
+ ]
52
+ artifacts = frontend.get("artifacts") or {}
53
+ base = str(artifacts.get("baseDirectory") or "").strip().strip("/")
54
+
55
+ if not base:
56
+ raise DeployError("amplify.yml has no frontend.artifacts.baseDirectory")
57
+
58
+ return cls(
59
+ commands=commands,
60
+ base=base,
61
+ files=[str(f) for f in artifacts.get("files") or ["**/*"]],
62
+ )
63
+
64
+ @property
65
+ def runnable(self) -> list[str]:
66
+ """The commands the platform runs: `nvm use` is Amplify's image choosing Node, which the worker already has."""
67
+ return [c for c in self.commands if not c.strip().startswith(SKIPPED)]
68
+
69
+ @property
70
+ def tools(self) -> list[str]:
71
+ return sorted({c.split()[0] for c in self.runnable if c.split()})
72
+
73
+
74
+ def server_of(package_json: str | None) -> str | None:
75
+ """The HTTP server framework a Node app depends on, which a static host cannot run."""
76
+ if not package_json:
77
+ return None
78
+
79
+ try:
80
+ deps = json.loads(package_json).get("dependencies") or {}
81
+ except (ValueError, AttributeError):
82
+ return None
83
+
84
+ return next((name for name in SERVERS if name in deps), None)
85
+
86
+
87
+ def build_env() -> dict[str, str]:
88
+ """The build's environment: the process's without AWS credentials or the platform's connection options, which the repository's commands never need."""
89
+ return {
90
+ k: v for k, v in os.environ.items() if not k.startswith(("AWS_", "AP_"))
91
+ } | {"CI": "true"}
92
+
93
+
94
+ def build(root: Path, spec: Buildspec) -> Path:
95
+ """Run the buildspec's commands in `root`; the directory its artifacts are in."""
96
+ for skipped in sorted(set(spec.commands) - set(spec.runnable)):
97
+ emit(f"aws/amplify: skipped `{skipped}`, the platform's Node is used")
98
+
99
+ if spec.runnable:
100
+ script = "set -e\n" + "\n".join(spec.runnable)
101
+ result = stream(
102
+ [shutil.which("bash") or "bash", "-c", script],
103
+ cwd=root,
104
+ env=build_env(),
105
+ )
106
+
107
+ if not result.ok:
108
+ raise DeployError(
109
+ f"the amplify.yml build failed: {result.output.strip()[-1500:]}"
110
+ )
111
+
112
+ out = root / spec.base
113
+
114
+ if not out.is_dir():
115
+ raise DeployError(
116
+ f"amplify.yml's artifacts.baseDirectory {spec.base}/ is not there after the build: "
117
+ "the build writes elsewhere, or the app is not a static site"
118
+ )
119
+
120
+ return out
121
+
122
+
123
+ def archive(out: Path, patterns: list[str]) -> bytes:
124
+ """The artifacts under `out` that match `patterns`, zipped with `out` as the root."""
125
+ buffer = io.BytesIO()
126
+ count = 0
127
+
128
+ with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as zf:
129
+ for path in sorted(out.rglob("*")):
130
+ if not path.is_file():
131
+ continue
132
+
133
+ name = path.relative_to(out).as_posix()
134
+
135
+ if any(matches(name, p) for p in patterns):
136
+ zf.write(path, name)
137
+ count += 1
138
+
139
+ if not count:
140
+ raise DeployError(f"no file under {out.name}/ matches {patterns}")
141
+
142
+ return buffer.getvalue()
143
+
144
+
145
+ def matches(name: str, pattern: str) -> bool:
146
+ if pattern in ("**/*", "**"):
147
+ return True
148
+
149
+ if pattern.startswith("**/"):
150
+ return fnmatch.fnmatch(name, pattern) or fnmatch.fnmatch(name, pattern[3:])
151
+
152
+ return fnmatch.fnmatch(name, pattern)