cdk-glue-iceberg-table 0.1.9 → 0.1.11
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/README.md +44 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# cdk-glue-iceberg-table
|
|
2
2
|
|
|
3
|
+
[](https://github.com/ksco92/arceus/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/ksco92/arceus)
|
|
3
5
|
[](https://www.npmjs.com/package/cdk-glue-iceberg-table)
|
|
6
|
+
[](https://www.npmjs.com/package/cdk-glue-iceberg-table)
|
|
7
|
+
[](https://www.npmjs.com/package/cdk-glue-iceberg-table)
|
|
8
|
+
[](https://github.com/ksco92/arceus/commits/main)
|
|
4
9
|
[](LICENSE)
|
|
5
10
|
|
|
6
11
|
A CDK L2 construct for Apache Iceberg tables in the AWS Glue Data
|
|
@@ -75,13 +80,13 @@ Consumer-facing reference sections below:
|
|
|
75
80
|
This repo is **both** the published package and a CDK demo app:
|
|
76
81
|
|
|
77
82
|
- `lib/iceberg/` — the published package (`cdk-glue-iceberg-table` on npm).
|
|
78
|
-
- `lib/arceus-stack.ts`, `lib/iceberg-evolution-stack.ts`, `lib/iceberg-dml-stack.ts`, `bin/`, `scripts/` — a CDK app that dogfoods the construct against a real AWS account, plus
|
|
83
|
+
- `lib/arceus-stack.ts`, `lib/iceberg-evolution-stack.ts`, `lib/iceberg-dml-stack.ts`, `lib/iceberg-surface-stack.ts`, `bin/`, `scripts/` — a CDK app that dogfoods the construct against a real AWS account, plus three bash harnesses: one drives schema + partition evolution through real `cdk deploy`s, one exercises the v2 DML surface (UPDATE / DELETE / MERGE / time travel / OPTIMIZE / VACUUM), and one covers the remaining surface (every partition transform, multi-field sort order, list / struct / map columns, and `grantRead` at runtime by assuming the grantee role and calling Glue / S3 directly). **Repo-only, not published to npm.**
|
|
79
84
|
- `e2e-consumer/` — a standalone CDK app that depends on the **published** `cdk-glue-iceberg-table` from npm. Proves that a fresh install + import + `cdk synth` works for downstream consumers. Runs on every PR via the `e2e-consumer` job in `.github/workflows/ci.yml`. Its `lib/surface-reference.ts` touches every exported symbol so that a rename in the published surface breaks CI. The pin in `e2e-consumer/package-lock.json` tracks the version most recently published to npm; CLAUDE.md asks for it to be bumped after each release.
|
|
80
85
|
|
|
81
86
|
How the test gates fit together:
|
|
82
87
|
|
|
83
88
|
- **`ci.yml`** runs on every PR — lint, unit tests with the 95% coverage gate, `npm pack`, and the `e2e-consumer` synth against the pinned published npm version.
|
|
84
|
-
- **`integ-test.yml`** is the real-AWS gate. Runs `scripts/integration-test-evolution.sh` (four `cdk deploy`s exercising schema + partition evolution),
|
|
89
|
+
- **`integ-test.yml`** is the real-AWS gate. Runs three scripts back-to-back: `scripts/integration-test-evolution.sh` (four `cdk deploy`s exercising schema + partition evolution), `scripts/integration-test-dml.sh` (one deploy, then UPDATE / DELETE / MERGE / time travel / OPTIMIZE / VACUUM against a v2 merge-on-read table), and `scripts/integration-test-surface.sh` (one deploy, then every partition transform, multi-field sort order, nested-type roundtrip, and `grantRead` at runtime via assume-role + direct Glue/S3 calls). Gated by `run-integ-test` label or `/run-integ-test` collaborator comment. PRs that touch any file under `lib/`, `bin/arceus.ts`, `cdk.json`, or any of the scripts must show a green run before merging (see CLAUDE.md §"Integration test for construct-touching PRs"). Doc-only PRs are exempt.
|
|
85
90
|
- **`publish.yml`** runs on push to `main` — trusted-publish to npm when `package.json`'s `version` is newer than the registry.
|
|
86
91
|
|
|
87
92
|
The sections [Prerequisites](#prerequisites), [Quickstart](#quickstart),
|
|
@@ -138,6 +143,7 @@ Repo source paths (npm consumers import from the package root and get the same e
|
|
|
138
143
|
- **`lib/arceus-stack.ts`**: the demo stack: KMS-encrypted data lake bucket, Athena results bucket, Glue database, three demo Iceberg tables (`orders`, `events`, `customers`). Repo-only, not in the npm tarball.
|
|
139
144
|
- **`lib/iceberg-evolution-stack.ts`** + **`scripts/integration-test-evolution.sh`**: a parameterized stack and a bash harness that drives four real `cdk deploy`s to prove schema/partition evolution works end-to-end. Repo-only, not in the npm tarball.
|
|
140
145
|
- **`lib/iceberg-dml-stack.ts`** + **`scripts/integration-test-dml.sh`**: a v2 merge-on-read table and a bash harness that exercises UPDATE, DELETE, MERGE INTO (upsert), time-travel SELECT, OPTIMIZE compaction, and VACUUM snapshot expiration. Single deploy, ~3 minutes. Repo-only, not in the npm tarball.
|
|
146
|
+
- **`lib/iceberg-surface-stack.ts`** + **`scripts/integration-test-surface.sh`**: three tables (one per concern) and a harness that verifies every partition transform renders the right `metadata.json`, a three-field sort order with mixed direction + null ordering, list/struct/map columns roundtrip through Athena, and `grantRead`'s four-statement IAM split actually authorizes (and denies cross-prefix) at runtime under an assumed grantee role. The same checks run against `IcebergTable.fromIcebergTableAttributes(...)` to prove the import factory's grant path is symmetric with the native one. Single deploy, ~4 minutes. Repo-only, not in the npm tarball.
|
|
141
147
|
|
|
142
148
|
## Quickstart
|
|
143
149
|
|
|
@@ -166,13 +172,13 @@ npx cdk deploy ArceusStack --require-approval=never
|
|
|
166
172
|
./scripts/integration-test-evolution.sh # add + rename + drop, via cdk only
|
|
167
173
|
```
|
|
168
174
|
|
|
169
|
-
`cdk ls` will show
|
|
175
|
+
`cdk ls` will show four stacks: `ArceusStack` (the demo data lake +
|
|
170
176
|
three Iceberg tables), `IcebergEvolutionStack` (the evolution test
|
|
171
|
-
target
|
|
172
|
-
`
|
|
173
|
-
|
|
174
|
-
the
|
|
175
|
-
|
|
177
|
+
target), `IcebergDmlStack` (the DML test target), and
|
|
178
|
+
`IcebergSurfaceStack` (the transforms / sort / nested-types /
|
|
179
|
+
grants test target). Deploy only `ArceusStack` for the quickstart;
|
|
180
|
+
the three test stacks are created on demand by their respective
|
|
181
|
+
scripts under `scripts/`.
|
|
176
182
|
|
|
177
183
|
## Using `IcebergTable`
|
|
178
184
|
|
|
@@ -563,8 +569,32 @@ table with `identifierFieldNames: ['account_id']`:
|
|
|
563
569
|
|
|
564
570
|
The DML table is configured with `history.expire.max-snapshot-age-ms`
|
|
565
571
|
of 60 seconds so VACUUM has snapshots to expire on a fresh table.
|
|
566
|
-
|
|
567
|
-
evolution
|
|
572
|
+
All three scripts run sequentially in the same `integ-test.yml`
|
|
573
|
+
job; evolution takes ~5 minutes, DML ~3, and surface ~4.
|
|
574
|
+
|
|
575
|
+
## Partition transforms, sort order, nested types, and grants
|
|
576
|
+
|
|
577
|
+
`scripts/integration-test-surface.sh` covers the slice of the
|
|
578
|
+
construct surface the evolution and DML stacks don't reach.
|
|
579
|
+
`IcebergSurfaceStack` defines three small tables that each isolate
|
|
580
|
+
one concern:
|
|
581
|
+
|
|
582
|
+
| Concern | Table | What the script checks |
|
|
583
|
+
| --- | --- | --- |
|
|
584
|
+
| **Every partition transform** | `transforms_test` (separate `year_source` / `month_source` / `day_source` / `hour_source` timestamps to avoid Iceberg's redundant-temporal-transform rejection, plus `user_id` / `email` / `value`) | `metadata.json` contains all seven transforms (`year`, `month`, `day`, `hour`, `bucket[8]`, `truncate[4]`, `identity`); INSERT one row and verify the resulting S3 prefix contains the expected multi-transform layout (`year_source_year=...`, `month_source_month=...`, etc.) |
|
|
585
|
+
| **Sort order** | `sorted_test` (`tenant`, `created_at`, `amount`) | `metadata.json`'s `sort-orders` block has three fields with the expected direction + null-order pairs: `asc/nulls-first`, `desc/nulls-last`, `desc/nulls-last` |
|
|
586
|
+
| **Nested types** | `nested_test` (`tags` list, `profile` struct, `attrs` map) | INSERT two rows using `ARRAY[...]`, `CAST(ROW(...) AS ROW(...))`, and `MAP(ARRAY[...], ARRAY[...])`. SELECT verifies `tags[1]`, `profile.first_name`, and `element_at(attrs, 'tier')` all roundtrip correctly |
|
|
587
|
+
| **`grantRead` S3 statements at runtime** | `transforms_test` + a `GranteeRole` trusted by the deployer | Assume the role and call S3 directly (Lake Formation doesn't gate S3 calls when the bucket is registered with `hybridAccessEnabled: true`, so the IAM grants the construct produces are what's being tested). `s3:ListBucket` on the table's own prefix succeeds. `s3:ListBucket` on a foreign table's prefix is denied — the `s3:prefix` condition kicks in. The Glue action grants are validated by the unit tests, not at runtime, because LF gates `glue:*` against tables in LF-registered locations regardless of the principal's IAM policy |
|
|
588
|
+
| **`fromIcebergTableAttributes(...)` + `grantRead`** | imported handle on `transforms_test` + a second `ImportedGranteeRole` | Same S3 checks under the import-factory grantee. Verifies the import path produces a symmetric IAM split |
|
|
589
|
+
|
|
590
|
+
The construct's `grantRead` / `grantWrite` / `grantReadWrite` issue
|
|
591
|
+
**IAM grants only**. In a Lake-Formation-managed deployment like
|
|
592
|
+
`ArceusStack`, Athena queries still need separate LF `SELECT` /
|
|
593
|
+
`INSERT` / `DELETE` grants on top of the construct's IAM grants. The
|
|
594
|
+
surface test deliberately bypasses Athena (assumes the role and
|
|
595
|
+
calls Glue + S3 directly) so the construct's grant logic is
|
|
596
|
+
verified in isolation — under LF, the IAM grants alone are
|
|
597
|
+
necessary but not sufficient for Athena queries.
|
|
568
598
|
|
|
569
599
|
## Two footguns the construct prevents
|
|
570
600
|
|
|
@@ -648,6 +678,7 @@ arceus/
|
|
|
648
678
|
│ ├── arceus-stack.ts # Demo stack (buckets, DB, 3 demo tables)
|
|
649
679
|
│ ├── iceberg-evolution-stack.ts # Parameterized stack for the evolution test
|
|
650
680
|
│ ├── iceberg-dml-stack.ts # Stack for the DML / time-travel / OPTIMIZE / VACUUM test
|
|
681
|
+
│ ├── iceberg-surface-stack.ts # Stack for transforms / sort / nested types / grants test
|
|
651
682
|
│ └── iceberg/
|
|
652
683
|
│ ├── iceberg-table.ts # The L2 construct itself
|
|
653
684
|
│ ├── iceberg-type.ts # IcebergType + struct/list/map/decimal/fixed
|
|
@@ -658,6 +689,7 @@ arceus/
|
|
|
658
689
|
│ ├── arceus-stack.test.ts
|
|
659
690
|
│ ├── iceberg-evolution-stack.test.ts
|
|
660
691
|
│ ├── iceberg-dml-stack.test.ts
|
|
692
|
+
│ ├── iceberg-surface-stack.test.ts
|
|
661
693
|
│ └── iceberg/
|
|
662
694
|
│ ├── iceberg-partition-transform.test.ts
|
|
663
695
|
│ ├── iceberg-table-properties.test.ts
|
|
@@ -674,7 +706,8 @@ arceus/
|
|
|
674
706
|
│ # rename in the published surface breaks CI
|
|
675
707
|
├── scripts/
|
|
676
708
|
│ ├── integration-test-evolution.sh # End-to-end evolution harness
|
|
677
|
-
│
|
|
709
|
+
│ ├── integration-test-dml.sh # End-to-end DML harness
|
|
710
|
+
│ └── integration-test-surface.sh # End-to-end surface harness
|
|
678
711
|
├── docs/
|
|
679
712
|
│ └── integ-test-setup.md # AWS-side prerequisites for the integ-test
|
|
680
713
|
│ # workflow (OIDC provider, IAM role, repo var)
|