cdk-glue-iceberg-table 0.1.9 → 0.1.10
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 +39 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,13 +75,13 @@ Consumer-facing reference sections below:
|
|
|
75
75
|
This repo is **both** the published package and a CDK demo app:
|
|
76
76
|
|
|
77
77
|
- `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
|
|
78
|
+
- `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
79
|
- `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
80
|
|
|
81
81
|
How the test gates fit together:
|
|
82
82
|
|
|
83
83
|
- **`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),
|
|
84
|
+
- **`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
85
|
- **`publish.yml`** runs on push to `main` — trusted-publish to npm when `package.json`'s `version` is newer than the registry.
|
|
86
86
|
|
|
87
87
|
The sections [Prerequisites](#prerequisites), [Quickstart](#quickstart),
|
|
@@ -138,6 +138,7 @@ Repo source paths (npm consumers import from the package root and get the same e
|
|
|
138
138
|
- **`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
139
|
- **`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
140
|
- **`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.
|
|
141
|
+
- **`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
142
|
|
|
142
143
|
## Quickstart
|
|
143
144
|
|
|
@@ -166,13 +167,13 @@ npx cdk deploy ArceusStack --require-approval=never
|
|
|
166
167
|
./scripts/integration-test-evolution.sh # add + rename + drop, via cdk only
|
|
167
168
|
```
|
|
168
169
|
|
|
169
|
-
`cdk ls` will show
|
|
170
|
+
`cdk ls` will show four stacks: `ArceusStack` (the demo data lake +
|
|
170
171
|
three Iceberg tables), `IcebergEvolutionStack` (the evolution test
|
|
171
|
-
target
|
|
172
|
-
`
|
|
173
|
-
|
|
174
|
-
the
|
|
175
|
-
|
|
172
|
+
target), `IcebergDmlStack` (the DML test target), and
|
|
173
|
+
`IcebergSurfaceStack` (the transforms / sort / nested-types /
|
|
174
|
+
grants test target). Deploy only `ArceusStack` for the quickstart;
|
|
175
|
+
the three test stacks are created on demand by their respective
|
|
176
|
+
scripts under `scripts/`.
|
|
176
177
|
|
|
177
178
|
## Using `IcebergTable`
|
|
178
179
|
|
|
@@ -563,8 +564,32 @@ table with `identifierFieldNames: ['account_id']`:
|
|
|
563
564
|
|
|
564
565
|
The DML table is configured with `history.expire.max-snapshot-age-ms`
|
|
565
566
|
of 60 seconds so VACUUM has snapshots to expire on a fresh table.
|
|
566
|
-
|
|
567
|
-
evolution
|
|
567
|
+
All three scripts run sequentially in the same `integ-test.yml`
|
|
568
|
+
job; evolution takes ~5 minutes, DML ~3, and surface ~4.
|
|
569
|
+
|
|
570
|
+
## Partition transforms, sort order, nested types, and grants
|
|
571
|
+
|
|
572
|
+
`scripts/integration-test-surface.sh` covers the slice of the
|
|
573
|
+
construct surface the evolution and DML stacks don't reach.
|
|
574
|
+
`IcebergSurfaceStack` defines three small tables that each isolate
|
|
575
|
+
one concern:
|
|
576
|
+
|
|
577
|
+
| Concern | Table | What the script checks |
|
|
578
|
+
| --- | --- | --- |
|
|
579
|
+
| **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.) |
|
|
580
|
+
| **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` |
|
|
581
|
+
| **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 |
|
|
582
|
+
| **`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 |
|
|
583
|
+
| **`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 |
|
|
584
|
+
|
|
585
|
+
The construct's `grantRead` / `grantWrite` / `grantReadWrite` issue
|
|
586
|
+
**IAM grants only**. In a Lake-Formation-managed deployment like
|
|
587
|
+
`ArceusStack`, Athena queries still need separate LF `SELECT` /
|
|
588
|
+
`INSERT` / `DELETE` grants on top of the construct's IAM grants. The
|
|
589
|
+
surface test deliberately bypasses Athena (assumes the role and
|
|
590
|
+
calls Glue + S3 directly) so the construct's grant logic is
|
|
591
|
+
verified in isolation — under LF, the IAM grants alone are
|
|
592
|
+
necessary but not sufficient for Athena queries.
|
|
568
593
|
|
|
569
594
|
## Two footguns the construct prevents
|
|
570
595
|
|
|
@@ -648,6 +673,7 @@ arceus/
|
|
|
648
673
|
│ ├── arceus-stack.ts # Demo stack (buckets, DB, 3 demo tables)
|
|
649
674
|
│ ├── iceberg-evolution-stack.ts # Parameterized stack for the evolution test
|
|
650
675
|
│ ├── iceberg-dml-stack.ts # Stack for the DML / time-travel / OPTIMIZE / VACUUM test
|
|
676
|
+
│ ├── iceberg-surface-stack.ts # Stack for transforms / sort / nested types / grants test
|
|
651
677
|
│ └── iceberg/
|
|
652
678
|
│ ├── iceberg-table.ts # The L2 construct itself
|
|
653
679
|
│ ├── iceberg-type.ts # IcebergType + struct/list/map/decimal/fixed
|
|
@@ -658,6 +684,7 @@ arceus/
|
|
|
658
684
|
│ ├── arceus-stack.test.ts
|
|
659
685
|
│ ├── iceberg-evolution-stack.test.ts
|
|
660
686
|
│ ├── iceberg-dml-stack.test.ts
|
|
687
|
+
│ ├── iceberg-surface-stack.test.ts
|
|
661
688
|
│ └── iceberg/
|
|
662
689
|
│ ├── iceberg-partition-transform.test.ts
|
|
663
690
|
│ ├── iceberg-table-properties.test.ts
|
|
@@ -674,7 +701,8 @@ arceus/
|
|
|
674
701
|
│ # rename in the published surface breaks CI
|
|
675
702
|
├── scripts/
|
|
676
703
|
│ ├── integration-test-evolution.sh # End-to-end evolution harness
|
|
677
|
-
│
|
|
704
|
+
│ ├── integration-test-dml.sh # End-to-end DML harness
|
|
705
|
+
│ └── integration-test-surface.sh # End-to-end surface harness
|
|
678
706
|
├── docs/
|
|
679
707
|
│ └── integ-test-setup.md # AWS-side prerequisites for the integ-test
|
|
680
708
|
│ # workflow (OIDC provider, IAM role, repo var)
|