@layertwo/cdk-constructs 0.0.0-stage → 0.0.12
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.
- package/.jsii +11085 -0
- package/AGENTS.md +153 -0
- package/API.md +8057 -0
- package/LICENSE +202 -0
- package/README.md +156 -2
- package/docs/plans/2026-02-18-github-packages-npm.md +120 -0
- package/lib/acm.d.ts +23 -0
- package/lib/acm.js +20 -0
- package/lib/dynamodb.d.ts +18 -0
- package/lib/dynamodb.js +22 -0
- package/lib/iam.d.ts +44 -0
- package/lib/iam.js +61 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +23 -0
- package/lib/lambda.d.ts +31 -0
- package/lib/lambda.js +53 -0
- package/lib/s3.d.ts +20 -0
- package/lib/s3.js +26 -0
- package/lib/uv-bundling.d.ts +78 -0
- package/lib/uv-bundling.js +193 -0
- package/package.json +127 -4
- package/renovate.json5 +45 -0
- package/resources/Dockerfile +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,157 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @layertwo/cdk-constructs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reusable [AWS CDK](https://aws.amazon.com/cdk/) constructs with secure defaults baked in, for TypeScript projects.
|
|
4
|
+
|
|
5
|
+
Published to [npm](https://www.npmjs.com/package/@layertwo/cdk-constructs) as a JSII library. Only the TypeScript/JS package is published.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @layertwo/cdk-constructs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Constructs
|
|
14
|
+
|
|
15
|
+
| Construct | Extends | Enforced behaviour |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| `SecureBucket` | `s3.Bucket` | Blocks all public access, S3-managed encryption, SSL enforced. Versioning on by default (`versioned: false` to opt out). |
|
|
18
|
+
| `SecureTable` | `dynamodb.Table` | On-demand billing (`PAY_PER_REQUEST`), point-in-time recovery always enabled. |
|
|
19
|
+
| `GitHubOidcRole` | `iam.Role` | Role assumable by GitHub Actions via OIDC, scoped to a repo and optionally a branch or environment. |
|
|
20
|
+
| `DnsValidatedCertificate` | `certificatemanager.Certificate` | Always DNS-validated against the supplied Route53 hosted zone. |
|
|
21
|
+
| `PythonFunction` | `lambda.Function` | Bundles a `uv` project in Docker, hashes the source tree (no re-upload when nothing changed), ARM64 + Python 3.15 by default. |
|
|
22
|
+
|
|
23
|
+
Everything marked *enforced* is hardcoded after your props are spread in — passing your own value for it is silently ignored. All other props pass straight through to the parent construct.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import * as path from "node:path";
|
|
29
|
+
import {
|
|
30
|
+
DnsValidatedCertificate,
|
|
31
|
+
GitHubOidcRole,
|
|
32
|
+
PythonFunction,
|
|
33
|
+
SecureBucket,
|
|
34
|
+
SecureTable,
|
|
35
|
+
} from "@layertwo/cdk-constructs";
|
|
36
|
+
import { HostedZone } from "aws-cdk-lib/aws-route53";
|
|
37
|
+
|
|
38
|
+
// S3: public access blocked, encrypted, SSL-only, versioned
|
|
39
|
+
const bucket = new SecureBucket(this, "Assets");
|
|
40
|
+
|
|
41
|
+
// DynamoDB: on-demand + PITR
|
|
42
|
+
const table = new SecureTable(this, "Sessions", {
|
|
43
|
+
partitionKey: { name: "id", type: dynamodb.AttributeType.STRING },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// IAM role for a GitHub Actions workflow on main
|
|
47
|
+
const deployRole = new GitHubOidcRole(this, "DeployRole", {
|
|
48
|
+
owner: "layertwo",
|
|
49
|
+
repo: "my-app",
|
|
50
|
+
branch: "main",
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// ACM certificate validated via Route53
|
|
54
|
+
new DnsValidatedCertificate(this, "Cert", {
|
|
55
|
+
domainName: "example.com",
|
|
56
|
+
hostedZone: HostedZone.fromLookup(this, "Zone", { domainName: "example.com" }),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Python Lambda from a uv project (built in Docker at synth time)
|
|
60
|
+
new PythonFunction(this, "Fetcher", {
|
|
61
|
+
rootDir: path.join(__dirname, "../services/fetcher"),
|
|
62
|
+
index: "src/entrypoint/__init__.py",
|
|
63
|
+
handler: "handle_event",
|
|
64
|
+
environment: { TABLE_NAME: table.tableName },
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Python bundling and caching
|
|
69
|
+
|
|
70
|
+
`PythonFunction` builds inside AWS's SAM build image for the Python version, so it needs Docker at synth time. The image ships `uv` and a C toolchain, and its glibc matches Lambda. The asset is fingerprinted from the project source — `uv.lock` changes rebuild it, caches and `.venv` do not.
|
|
71
|
+
|
|
72
|
+
Two things make that fast in CI:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# Skip bundling entirely when the source hash matches a previous run.
|
|
76
|
+
- uses: actions/cache@v4
|
|
77
|
+
with:
|
|
78
|
+
path: cdk.out
|
|
79
|
+
key: cdk-assets-${{ github.sha }}
|
|
80
|
+
restore-keys: cdk-assets-
|
|
81
|
+
|
|
82
|
+
# Cache the image layers; type=gha needs BuildKit, and fails on a plain local daemon.
|
|
83
|
+
- uses: docker/setup-buildx-action@v3
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const cacheScope = "lambda-bundling";
|
|
88
|
+
new PythonFunction(this, "Fetcher", {
|
|
89
|
+
rootDir,
|
|
90
|
+
bundling: process.env.CI
|
|
91
|
+
? {
|
|
92
|
+
cacheFrom: [{ type: "gha", params: { scope: cacheScope } }],
|
|
93
|
+
cacheTo: { type: "gha", params: { mode: "max", scope: cacheScope } },
|
|
94
|
+
}
|
|
95
|
+
: {},
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The default image is AWS's SAM build image for the selected Python version, so dependencies that need a C toolchain build normally. Pass `bundling.image` to use your own build image.
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
This project uses [Projen](https://projen.io/) for configuration and build management. Configuration lives in `.projenrc.ts`.
|
|
104
|
+
|
|
105
|
+
### Setup
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
yarn install
|
|
109
|
+
npx projen # regenerate project files from .projenrc.ts
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Node.js 22 or 24 (the versions jsii supports). Dependency upgrades arrive as Renovate PRs — there is no local upgrade task.
|
|
113
|
+
|
|
114
|
+
### Common commands
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm run build # full build: compile (jsii) + test + package
|
|
118
|
+
npm run compile # compile TypeScript only
|
|
119
|
+
npm test # tests with coverage
|
|
120
|
+
npm run test:watch # tests in watch mode
|
|
121
|
+
npm run eslint # linter
|
|
122
|
+
npm run package # generate distributable packages
|
|
123
|
+
npx projen # re-synthesize generated files
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Making changes
|
|
127
|
+
|
|
128
|
+
1. Add the construct in `src/` and export it from `src/index.ts`.
|
|
129
|
+
2. Add a matching `test/<name>.test.ts` using CDK assertions.
|
|
130
|
+
3. Run `npm run build`.
|
|
131
|
+
4. For build/config changes, edit `.projenrc.ts` and run `npx projen`.
|
|
132
|
+
|
|
133
|
+
Do not edit files marked `~~ Generated by projen` — change `.projenrc.ts` and regenerate instead.
|
|
134
|
+
|
|
135
|
+
## Technology Stack
|
|
136
|
+
|
|
137
|
+
- **Language**: TypeScript 5.9
|
|
138
|
+
- **Framework**: AWS CDK 2.275.0
|
|
139
|
+
- **Testing**: Jest 30 with ts-jest and CDK assertions
|
|
140
|
+
- **Linting**: ESLint 9 + Prettier
|
|
141
|
+
- **Publishing**: JSII
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
Ensure `npm run build` passes before opening a PR. Commits on `mainline` follow conventional commits; the release workflow bumps the version and publishes.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
Apache-2.0
|
|
150
|
+
|
|
151
|
+
## Author
|
|
152
|
+
|
|
153
|
+
Lucas Messenger (1335960+layertwo@users.noreply.github.com)
|
|
154
|
+
|
|
155
|
+
## Repository
|
|
156
|
+
|
|
157
|
+
https://github.com/layertwo/cdk-constructs
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# GitHub Packages npm Publishing Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
|
4
|
+
|
|
5
|
+
**Goal:** Replace registry.npmjs.org npm publishing with GitHub Packages (npm.pkg.github.com) using the built-in GITHUB_TOKEN.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Update `.projenrc.ts` with four projen options to change the package name to a scoped form, point the registry at GitHub Packages, swap the auth token to GITHUB_TOKEN, and grant the release workflow `packages: write` permission. Run `npx projen` to regenerate all managed files.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** projen (`awscdk.AwsCdkConstructLibrary`), GitHub Actions, publib-npm
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
### Task 1: Update `.projenrc.ts` with GitHub Packages options
|
|
14
|
+
|
|
15
|
+
**Files:**
|
|
16
|
+
- Modify: `.projenrc.ts`
|
|
17
|
+
|
|
18
|
+
**Step 1: Open the file and confirm current state**
|
|
19
|
+
|
|
20
|
+
Read `.projenrc.ts` and verify it contains:
|
|
21
|
+
- `name: "layertwo-cdk-constructs"`
|
|
22
|
+
- `publishToPypi: { ... }` block
|
|
23
|
+
- `mutableBuild: true`
|
|
24
|
+
- `depsUpgrade: false`
|
|
25
|
+
|
|
26
|
+
**Step 2: Add the four new options**
|
|
27
|
+
|
|
28
|
+
Edit `.projenrc.ts` so the project constructor looks like this (add the four lines after `depsUpgrade: false`):
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { awscdk, github } from "projen";
|
|
32
|
+
const project = new awscdk.AwsCdkConstructLibrary({
|
|
33
|
+
author: "Lucas Messenger",
|
|
34
|
+
authorAddress: "1335960+layertwo@users.noreply.github.com",
|
|
35
|
+
cdkVersion: "2.200.0",
|
|
36
|
+
defaultReleaseBranch: "mainline",
|
|
37
|
+
jsiiVersion: "~5.9.0",
|
|
38
|
+
name: "layertwo-cdk-constructs",
|
|
39
|
+
projenrcTs: true,
|
|
40
|
+
repositoryUrl: "https://github.com/layertwo/cdk-constructs",
|
|
41
|
+
renovatebot: true,
|
|
42
|
+
mergify: false,
|
|
43
|
+
vscode: true,
|
|
44
|
+
prettier: true,
|
|
45
|
+
publishToPypi: {
|
|
46
|
+
distName: "layertwo-cdk-constructs",
|
|
47
|
+
module: "layertwo_cdk_constructs",
|
|
48
|
+
},
|
|
49
|
+
mutableBuild: true,
|
|
50
|
+
depsUpgrade: false,
|
|
51
|
+
packageName: "@layertwo/cdk-constructs",
|
|
52
|
+
npmRegistryUrl: "https://npm.pkg.github.com",
|
|
53
|
+
npmTokenSecret: "GITHUB_TOKEN",
|
|
54
|
+
workflowPermissions: {
|
|
55
|
+
packages: github.workflows.JobPermission.WRITE,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
project.synth();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Note the import line changes from `import { awscdk } from "projen"` to `import { awscdk, github } from "projen"` to access `JobPermission`.
|
|
62
|
+
|
|
63
|
+
**Step 3: Run projen to regenerate managed files**
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx projen
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Expected: projen regenerates `.github/workflows/release.yml`, `package.json`, `renovate.json5`, and related files without errors.
|
|
70
|
+
|
|
71
|
+
**Step 4: Verify the release workflow is correct**
|
|
72
|
+
|
|
73
|
+
Open `.github/workflows/release.yml` and confirm:
|
|
74
|
+
|
|
75
|
+
1. The `release_npm` job's `env` block contains:
|
|
76
|
+
```yaml
|
|
77
|
+
NPM_REGISTRY: npm.pkg.github.com
|
|
78
|
+
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
79
|
+
```
|
|
80
|
+
(and `NPM_CONFIG_PROVENANCE: "true"` is gone)
|
|
81
|
+
|
|
82
|
+
2. The `release` job (or workflow-level) has `packages: write` permission.
|
|
83
|
+
|
|
84
|
+
3. `NPM_DIST_TAG: latest` is still present.
|
|
85
|
+
|
|
86
|
+
**Step 5: Verify package.json has the scoped name**
|
|
87
|
+
|
|
88
|
+
Open `package.json` and confirm:
|
|
89
|
+
```json
|
|
90
|
+
"name": "@layertwo/cdk-constructs"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Step 6: Commit**
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git add .projenrc.ts .github/workflows/release.yml package.json
|
|
97
|
+
git add .gitattributes .gitignore .projen/files.json .projen/tasks.json renovate.json5
|
|
98
|
+
git commit -m "feat: publish npm package to GitHub Packages"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Task 2: Push and verify the release workflow
|
|
104
|
+
|
|
105
|
+
**Files:** none (CI verification)
|
|
106
|
+
|
|
107
|
+
**Step 1: Push to mainline**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
git push
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Step 2: Check the Actions tab**
|
|
114
|
+
|
|
115
|
+
Go to `https://github.com/layertwo/cdk-constructs/actions` and confirm:
|
|
116
|
+
- The `release` workflow triggered on push to `mainline`
|
|
117
|
+
- If a new version is released, the `release_npm` job succeeds
|
|
118
|
+
- The package appears at `https://github.com/layertwo?tab=packages`
|
|
119
|
+
|
|
120
|
+
> **Note:** If no version bump is detected, no `release_npm` job will run — that is expected behaviour. To trigger a real publish, a commit with a conventional-commits feat/fix message and a version bump is needed.
|
package/lib/acm.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Certificate, CertificateProps } from "aws-cdk-lib/aws-certificatemanager";
|
|
2
|
+
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
/**
|
|
5
|
+
* Properties for DnsValidatedCertificate.
|
|
6
|
+
*
|
|
7
|
+
* The `validation` prop from CertificateProps is always overridden to use
|
|
8
|
+
* DNS validation via the supplied `hostedZone`. Any value passed for
|
|
9
|
+
* `validation` will be silently ignored.
|
|
10
|
+
*/
|
|
11
|
+
export interface DnsValidatedCertificateProps extends CertificateProps {
|
|
12
|
+
/**
|
|
13
|
+
* The Route53 hosted zone to use for DNS validation.
|
|
14
|
+
*/
|
|
15
|
+
readonly hostedZone: IHostedZone;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An ACM Certificate that always uses Route53 DNS validation.
|
|
19
|
+
* Pass a `hostedZone` instead of a `validation` prop.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DnsValidatedCertificate extends Certificate {
|
|
22
|
+
constructor(scope: Construct, id: string, props: DnsValidatedCertificateProps);
|
|
23
|
+
}
|
package/lib/acm.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DnsValidatedCertificate = void 0;
|
|
4
|
+
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
|
5
|
+
const aws_certificatemanager_1 = require("aws-cdk-lib/aws-certificatemanager");
|
|
6
|
+
/**
|
|
7
|
+
* An ACM Certificate that always uses Route53 DNS validation.
|
|
8
|
+
* Pass a `hostedZone` instead of a `validation` prop.
|
|
9
|
+
*/
|
|
10
|
+
class DnsValidatedCertificate extends aws_certificatemanager_1.Certificate {
|
|
11
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "@layertwo/cdk-constructs.DnsValidatedCertificate", version: "0.0.12" };
|
|
12
|
+
constructor(scope, id, props) {
|
|
13
|
+
super(scope, id, {
|
|
14
|
+
...props,
|
|
15
|
+
validation: aws_certificatemanager_1.CertificateValidation.fromDns(props.hostedZone),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.DnsValidatedCertificate = DnsValidatedCertificate;
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNtLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FjbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsK0VBSTRDO0FBa0I1Qzs7O0dBR0c7QUFDSCxNQUFhLHVCQUF3QixTQUFRLG9DQUFXOztJQUN0RCxZQUNFLEtBQWdCLEVBQ2hCLEVBQVUsRUFDVixLQUFtQztRQUVuQyxLQUFLLENBQUMsS0FBSyxFQUFFLEVBQUUsRUFBRTtZQUNmLEdBQUcsS0FBSztZQUNSLFVBQVUsRUFBRSw4Q0FBcUIsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLFVBQVUsQ0FBQztTQUM1RCxDQUFDLENBQUM7SUFDTCxDQUFDOztBQVZILDBEQVdDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtcbiAgQ2VydGlmaWNhdGUsXG4gIENlcnRpZmljYXRlUHJvcHMsXG4gIENlcnRpZmljYXRlVmFsaWRhdGlvbixcbn0gZnJvbSBcImF3cy1jZGstbGliL2F3cy1jZXJ0aWZpY2F0ZW1hbmFnZXJcIjtcbmltcG9ydCB7IElIb3N0ZWRab25lIH0gZnJvbSBcImF3cy1jZGstbGliL2F3cy1yb3V0ZTUzXCI7XG5pbXBvcnQgeyBDb25zdHJ1Y3QgfSBmcm9tIFwiY29uc3RydWN0c1wiO1xuXG4vKipcbiAqIFByb3BlcnRpZXMgZm9yIERuc1ZhbGlkYXRlZENlcnRpZmljYXRlLlxuICpcbiAqIFRoZSBgdmFsaWRhdGlvbmAgcHJvcCBmcm9tIENlcnRpZmljYXRlUHJvcHMgaXMgYWx3YXlzIG92ZXJyaWRkZW4gdG8gdXNlXG4gKiBETlMgdmFsaWRhdGlvbiB2aWEgdGhlIHN1cHBsaWVkIGBob3N0ZWRab25lYC4gQW55IHZhbHVlIHBhc3NlZCBmb3JcbiAqIGB2YWxpZGF0aW9uYCB3aWxsIGJlIHNpbGVudGx5IGlnbm9yZWQuXG4gKi9cbmV4cG9ydCBpbnRlcmZhY2UgRG5zVmFsaWRhdGVkQ2VydGlmaWNhdGVQcm9wcyBleHRlbmRzIENlcnRpZmljYXRlUHJvcHMge1xuICAvKipcbiAgICogVGhlIFJvdXRlNTMgaG9zdGVkIHpvbmUgdG8gdXNlIGZvciBETlMgdmFsaWRhdGlvbi5cbiAgICovXG4gIHJlYWRvbmx5IGhvc3RlZFpvbmU6IElIb3N0ZWRab25lO1xufVxuXG4vKipcbiAqIEFuIEFDTSBDZXJ0aWZpY2F0ZSB0aGF0IGFsd2F5cyB1c2VzIFJvdXRlNTMgRE5TIHZhbGlkYXRpb24uXG4gKiBQYXNzIGEgYGhvc3RlZFpvbmVgIGluc3RlYWQgb2YgYSBgdmFsaWRhdGlvbmAgcHJvcC5cbiAqL1xuZXhwb3J0IGNsYXNzIERuc1ZhbGlkYXRlZENlcnRpZmljYXRlIGV4dGVuZHMgQ2VydGlmaWNhdGUge1xuICBjb25zdHJ1Y3RvcihcbiAgICBzY29wZTogQ29uc3RydWN0LFxuICAgIGlkOiBzdHJpbmcsXG4gICAgcHJvcHM6IERuc1ZhbGlkYXRlZENlcnRpZmljYXRlUHJvcHMsXG4gICkge1xuICAgIHN1cGVyKHNjb3BlLCBpZCwge1xuICAgICAgLi4ucHJvcHMsXG4gICAgICB2YWxpZGF0aW9uOiBDZXJ0aWZpY2F0ZVZhbGlkYXRpb24uZnJvbURucyhwcm9wcy5ob3N0ZWRab25lKSxcbiAgICB9KTtcbiAgfVxufVxuIl19
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Table, TableProps } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
/**
|
|
4
|
+
* Properties for SecureTable.
|
|
5
|
+
*
|
|
6
|
+
* Hardcoded (not overridable): billingMode, pointInTimeRecoverySpecification.
|
|
7
|
+
* These are always applied regardless of what is passed in props.
|
|
8
|
+
*/
|
|
9
|
+
export interface SecureTableProps extends TableProps {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A DynamoDB Table with best-practice defaults enforced:
|
|
13
|
+
* - On-demand billing (PAY_PER_REQUEST)
|
|
14
|
+
* - Point-in-time recovery always enabled
|
|
15
|
+
*/
|
|
16
|
+
export declare class SecureTable extends Table {
|
|
17
|
+
constructor(scope: Construct, id: string, props: SecureTableProps);
|
|
18
|
+
}
|
package/lib/dynamodb.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecureTable = void 0;
|
|
4
|
+
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
|
5
|
+
const aws_dynamodb_1 = require("aws-cdk-lib/aws-dynamodb");
|
|
6
|
+
/**
|
|
7
|
+
* A DynamoDB Table with best-practice defaults enforced:
|
|
8
|
+
* - On-demand billing (PAY_PER_REQUEST)
|
|
9
|
+
* - Point-in-time recovery always enabled
|
|
10
|
+
*/
|
|
11
|
+
class SecureTable extends aws_dynamodb_1.Table {
|
|
12
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "@layertwo/cdk-constructs.SecureTable", version: "0.0.12" };
|
|
13
|
+
constructor(scope, id, props) {
|
|
14
|
+
super(scope, id, {
|
|
15
|
+
...props,
|
|
16
|
+
billingMode: aws_dynamodb_1.BillingMode.PAY_PER_REQUEST,
|
|
17
|
+
pointInTimeRecoverySpecification: { pointInTimeRecoveryEnabled: true },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.SecureTable = SecureTable;
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHluYW1vZGIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZHluYW1vZGIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLDJEQUEwRTtBQVcxRTs7OztHQUlHO0FBQ0gsTUFBYSxXQUFZLFNBQVEsb0JBQUs7O0lBQ3BDLFlBQVksS0FBZ0IsRUFBRSxFQUFVLEVBQUUsS0FBdUI7UUFDL0QsS0FBSyxDQUFDLEtBQUssRUFBRSxFQUFFLEVBQUU7WUFDZixHQUFHLEtBQUs7WUFDUixXQUFXLEVBQUUsMEJBQVcsQ0FBQyxlQUFlO1lBQ3hDLGdDQUFnQyxFQUFFLEVBQUUsMEJBQTBCLEVBQUUsSUFBSSxFQUFFO1NBQ3ZFLENBQUMsQ0FBQztJQUNMLENBQUM7O0FBUEgsa0NBUUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBCaWxsaW5nTW9kZSwgVGFibGUsIFRhYmxlUHJvcHMgfSBmcm9tIFwiYXdzLWNkay1saWIvYXdzLWR5bmFtb2RiXCI7XG5pbXBvcnQgeyBDb25zdHJ1Y3QgfSBmcm9tIFwiY29uc3RydWN0c1wiO1xuXG4vKipcbiAqIFByb3BlcnRpZXMgZm9yIFNlY3VyZVRhYmxlLlxuICpcbiAqIEhhcmRjb2RlZCAobm90IG92ZXJyaWRhYmxlKTogYmlsbGluZ01vZGUsIHBvaW50SW5UaW1lUmVjb3ZlcnlTcGVjaWZpY2F0aW9uLlxuICogVGhlc2UgYXJlIGFsd2F5cyBhcHBsaWVkIHJlZ2FyZGxlc3Mgb2Ygd2hhdCBpcyBwYXNzZWQgaW4gcHJvcHMuXG4gKi9cbmV4cG9ydCBpbnRlcmZhY2UgU2VjdXJlVGFibGVQcm9wcyBleHRlbmRzIFRhYmxlUHJvcHMge31cblxuLyoqXG4gKiBBIER5bmFtb0RCIFRhYmxlIHdpdGggYmVzdC1wcmFjdGljZSBkZWZhdWx0cyBlbmZvcmNlZDpcbiAqIC0gT24tZGVtYW5kIGJpbGxpbmcgKFBBWV9QRVJfUkVRVUVTVClcbiAqIC0gUG9pbnQtaW4tdGltZSByZWNvdmVyeSBhbHdheXMgZW5hYmxlZFxuICovXG5leHBvcnQgY2xhc3MgU2VjdXJlVGFibGUgZXh0ZW5kcyBUYWJsZSB7XG4gIGNvbnN0cnVjdG9yKHNjb3BlOiBDb25zdHJ1Y3QsIGlkOiBzdHJpbmcsIHByb3BzOiBTZWN1cmVUYWJsZVByb3BzKSB7XG4gICAgc3VwZXIoc2NvcGUsIGlkLCB7XG4gICAgICAuLi5wcm9wcyxcbiAgICAgIGJpbGxpbmdNb2RlOiBCaWxsaW5nTW9kZS5QQVlfUEVSX1JFUVVFU1QsXG4gICAgICBwb2ludEluVGltZVJlY292ZXJ5U3BlY2lmaWNhdGlvbjogeyBwb2ludEluVGltZVJlY292ZXJ5RW5hYmxlZDogdHJ1ZSB9LFxuICAgIH0pO1xuICB9XG59XG4iXX0=
|
package/lib/iam.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { Role } from "aws-cdk-lib/aws-iam";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
/**
|
|
5
|
+
* Properties for GitHubOidcRole
|
|
6
|
+
*/
|
|
7
|
+
export interface GitHubOidcRoleProps {
|
|
8
|
+
/**
|
|
9
|
+
* GitHub repository owner (organization or user)
|
|
10
|
+
*/
|
|
11
|
+
readonly owner: string;
|
|
12
|
+
/**
|
|
13
|
+
* GitHub repository name
|
|
14
|
+
*/
|
|
15
|
+
readonly repo: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specific branch to allow (optional)
|
|
18
|
+
* If neither branch nor environment is specified, all branches are allowed
|
|
19
|
+
*/
|
|
20
|
+
readonly branch?: string;
|
|
21
|
+
/**
|
|
22
|
+
* GitHub environment name (optional)
|
|
23
|
+
* Takes precedence over branch if both are specified
|
|
24
|
+
*/
|
|
25
|
+
readonly environment?: string;
|
|
26
|
+
/**
|
|
27
|
+
* A description of the role
|
|
28
|
+
* @default - No description
|
|
29
|
+
*/
|
|
30
|
+
readonly description?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The maximum session duration for the role
|
|
33
|
+
* @default Duration.hours(1)
|
|
34
|
+
*/
|
|
35
|
+
readonly maxSessionDuration?: Duration;
|
|
36
|
+
/**
|
|
37
|
+
* A name for the IAM role
|
|
38
|
+
* @default - AWS CloudFormation generates a unique physical ID
|
|
39
|
+
*/
|
|
40
|
+
readonly roleName?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare class GitHubOidcRole extends Role {
|
|
43
|
+
constructor(scope: Construct, id: string, props: GitHubOidcRoleProps);
|
|
44
|
+
}
|