cdk-glue-iceberg-table
AWS CDK L2 construct to create and evolve Apache Iceberg tables in the AWS Glue Data Catalog — schema and partition changes that survive CloudFormation updates, via cdk deploy.
Declare columns, partition specs, sort orders, and table properties in TypeScript or Python. Adding, renaming, dropping, or widening columns and evolving partition specs land as pull requests and apply in place through cdk deploy as a plain AWS::Glue::Table.
- Plain CloudFormation: emits
AWS::Glue::Tabledirectly with no custom resource, Lambda, or out-of-band DDL. - Safe
OpenTableFormatInputshape: puts schema, partitions, sort order, and properties undericebergTableInput, avoiding the two broken rawCfnTableforms (placing columns understorageDescriptor.columns, which breaks Athena after an update, or settingtableInputbesideicebergTableInput, which CloudFormation rejects at creation; see Why a raw CfnTable goes wrong). - Synth-time checks: validates field ids, column types, and transform-to-column compatibility in TypeScript and Python (jsii) across Iceberg format versions 1, 2, and 3.
Status (November 2026): Pre-1.0 (0.x, with 1.0 planned; breaking changes bump the minor version and record upgrade notes in UPGRADING.md). Published on npm, PyPI, and Construct Hub by one maintainer; Athena queries v2 tables only, not v3. Originally proposed for @aws-cdk/aws-glue-alpha in aws/aws-cdk#37988 (closed stale in September 2026), this package is maintained independently. GitHub main may be ahead of the latest registry release (see CHANGELOG.md).
Contents
Install
npm install cdk-glue-iceberg-table # TypeScript / JavaScript
pip install cdk-glue-iceberg-table # Python
Peer dependencies required in your CDK app (aws-cdk-lib >= 2.273.0, because Database is imported from stable aws-cdk-lib/aws-glue, and constructs >= 10.8.1):
npm install aws-cdk-lib@^2.273.0 constructs@^10.8.1 # TypeScript / JavaScript
pip install 'aws-cdk-lib>=2.273.0' 'constructs>=10.8.1' # Python
Both languages require Node.js 22.14 or newer (the Python package runs under it through jsii); Python requires 3.10 or newer. Upgrading from an earlier version: see UPGRADING.md (notes start at 0.12.0).
Quick start
Both examples go inside a stack's constructor in an existing CDK app. Required vs defaulted properties:
formatVersionis required (IcebergFormatVersion.V1,V2, orV3).dataFormatdefaults toIcebergDataFormat.PARQUET.removalPolicydefaults toRemovalPolicy.RETAIN.
Setting identifierFieldNames prepends (PK) to each identifier column's Glue comment (Identifier fields).
TypeScript
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { Database } from 'aws-cdk-lib/aws-glue';
import {
IcebergFormatVersion,
IcebergTable,
IcebergType,
IcebergPartitionTransform,
} from 'cdk-glue-iceberg-table';
const bucket = new Bucket(this, 'Warehouse');
const db = new Database(this, 'Db', { databaseName: 'analytics' });
new IcebergTable(this, 'OrdersTable', {
database: db,
tableName: 'orders',
location: `s3://${bucket.bucketName}/analytics/orders/`,
columns: [
{ name: 'order_id', type: IcebergType.LONG, required: true, id: 1 },
{ name: 'customer_id', type: IcebergType.LONG, required: true, id: 2 },
{ name: 'placed_at', type: IcebergType.TIMESTAMPTZ, required: true, id: 3 },
],
partitionSpec: [
{ sourceColumn: 'placed_at', transform: IcebergPartitionTransform.DAY, fieldId: 1000 },
{ sourceColumn: 'customer_id', transform: IcebergPartitionTransform.bucket(16), fieldId: 1001 },
],
identifierFieldNames: ['order_id'],
formatVersion: IcebergFormatVersion.V2,
});
cdk deploy creates the Glue Data Catalog table and writes Iceberg metadata.json under the S3 prefix in location. For a full example exercising nested list, struct, and map columns, decimal, sortOrder, tableProperties, and the resulting metadata.json, see docs/full-example.md.
Python
Props are snake_case and type names match TypeScript. Pass each column and partition field as IcebergColumn and IcebergPartitionField with snake_case arguments (a plain dict keeps TypeScript keys such as sourceColumn and fieldId):
from aws_cdk.aws_s3 import Bucket
from aws_cdk.aws_glue import Database
from cdk_glue_iceberg_table import (
IcebergColumn,
IcebergFormatVersion,
IcebergPartitionField,
IcebergPartitionTransform,
IcebergTable,
IcebergType,
)
bucket = Bucket(self, "Warehouse")
db = Database(self, "Db", database_name="analytics")
IcebergTable(self, "OrdersTable",
database=db,
table_name="orders",
location=f"s3://{bucket.bucket_name}/analytics/orders/",
columns=[
IcebergColumn(name="order_id", type=IcebergType.LONG, required=True, id=1),
IcebergColumn(name="customer_id", type=IcebergType.LONG, required=True, id=2),
IcebergColumn(name="placed_at", type=IcebergType.TIMESTAMPTZ, required=True, id=3),
],
partition_spec=[
IcebergPartitionField(source_column="placed_at", transform=IcebergPartitionTransform.DAY, field_id=1000),
IcebergPartitionField(source_column="customer_id", transform=IcebergPartitionTransform.bucket(16), field_id=1001),
],
identifier_field_names=["order_id"],
format_version=IcebergFormatVersion.V2,
)
The field id rules
id and fieldId are Iceberg field ids. Data files store values by field id rather than column name. IcebergTable validates ids within a single declaration (Columns and field ids, Partition fields), keeps no state across deploys, and leaves cross-deploy id hygiene to you:
- Declare a new table's ids in creation order (columns 1, 2, 3 in order, then nested fields): Glue numbers a new table this way regardless of declared ids; if the declared ids differ, the first update Glue accepts renumbers the fields to them, causing pre-update data files to read under the wrong field. Use
IcebergTable.creationOrderFieldIds(columns)(Creation order). - Keep each column's id for life and retire dropped column ids: A rename keeps the
idand changesname; a new column takes an id abovelast-column-id(how to read it). Giving a dropped column's id to a new column of the same type is accepted by Glue, causing Spark and Athena to read the dropped column's pre-drop values under the new column. - Use
fieldId >= 1000and never reuse a changed or dropped partition field's id: Changing a transform orsourceColumncreates a new partition field that needs afieldIdno partition spec of the table has used. Reassigning a prior id (such as givingbucket(8)the idbucket(4)held) is accepted by Glue and readable in Athena, while SparkSELECT *fails withValidationException: Conflicting partition fields. At creation Glue numbers partition fields sequentially from 1000 (Partition fields).
See docs/field-ids.md for worked examples and Preventing field-id reuse in team CI for an automated check.
Evolving a table
Edit columns or partitionSpec and run cdk deploy again. To add a column to the quick-start table, give it an id the table has never used:
columns: [
{ name: 'order_id', type: IcebergType.LONG, required: true, id: 1 },
{ name: 'customer_id', type: IcebergType.LONG, required: true, id: 2 },
{ name: 'placed_at', type: IcebergType.TIMESTAMPTZ, required: true, id: 3 },
{ name: 'currency', type: IcebergType.STRING, id: 4 }, // new
],
The construct sends the updated schema through Glue UpdateTable, which writes a new metadata.json and schema-id. Adds, renames (same id, new name), and drops apply in place through cdk deploy.
On a v2 table, promoting int to long, float to double, decimal(10, 2) to decimal(12, 2), and relaxing required: true to required: false in one update is accepted in place by Glue; field ids are preserved, and Athena reads pre-update rows and inserts widened and NULL rows. On a v3 table, Glue accepts unknown to string and date to timestamp in place. Narrowing or incompatible type changes are not observed against Glue.
Nested fields
Each struct field, list element, map key, and map value keeps its declared id across updates. Adding a nested field anywhere in the schema leaves existing ids unchanged; give each new nested field an unused id:
type: IcebergType.struct([
{ id: 10, name: 'line1', type: IcebergType.STRING },
{ id: 16, name: 'line2', type: IcebergType.STRING }, // new field, unused id
{ id: 11, name: 'city', type: IcebergType.STRING },
]),
Change the partition spec
To change from month(placed_at) to day(placed_at), replace the entry under a fresh fieldId (rule 3):
partitionSpec: [
// was: { sourceColumn: 'placed_at', transform: IcebergPartitionTransform.MONTH, fieldId: 1000 },
{
sourceColumn: 'placed_at',
transform: IcebergPartitionTransform.DAY,
fieldId: 1001,
},
],
Old data files written under the month spec stay readable; new writes partition by day.
Identifiers, sort order and table properties
identifierFieldNames updates flow through cdk deploy (for tables created with identifiers before 0.11.0, check Known limitations before removing the last identifier). sortOrder updates append a new entry under the next order-id in sort-orders and point default-sort-order-id at it, keeping earlier orders in the list. Changing tableProperties alone writes new metadata while preserving current-schema-id, partition spec, and sort order.
Changes that need care
-
Changing
locationon an existing table: CloudFormation updatesAWS::Glue::Tablein place (table-uuidis preserved, andmetadata.json'slocationand Glue'smetadata_locationmove to the new prefix while pre-move manifests and data files remain under the old prefix). Engines with direct S3 access to both prefixes (such as Spark overS3FileIO) read pre-move rows and write new rows under the new prefix. Athena querying through Lake Formation fails bothINSERT(before a new manifest list exists under the new prefix) andSELECT *withPERMISSION_DENIED(S3 403), because Lake Formation vends temporary S3 credentials scoped to the table's currentlocation, blocking access to pre-move manifests and data files under the old prefix. -
Dropping a column that a partition field has sourced breaks Athena: Glue accepts the update, and subsequent
SELECT *andSELECT count(*)queries in Athena fail withGENERIC_INTERNAL_ERROR: Type cannot be nullon pre-drop rows, whether the partition field was dropped in the same deploy or earlier. Keep source columns of historical partition fields incolumns. -
Glue ignores a V2 to V3
formatVersionchange: The table stays format 2 whileproperties.format-versionbecomes3. KeepformatVersionat the table's actual format version. -
Engine-side
ALTER TABLEdrift:- After Athena
ALTER TABLE ... ADD COLUMNS (w string)addswunder id 3 and writes a row withw, a deploy with the declaration unchanged leaves GlueVersionIdandmetadata_locationunchanged; a deploy that updates a table property without declaringwremoveswfrom the current schema (SELECT *omitsw); declaringwunder id 3 adds no schema and readsw; declaringwunder id 4 is accepted and readswasNULLin that row. - After Spark upgrades a v2 table to v3 via
SET TBLPROPERTIES ('format-version' = '3'), updateformatVersiontoIcebergFormatVersion.V3soproperties.format-versionmatches the format 3 table. Outcomes after other engine-sideALTER TABLEstatements are not observed.
- After Athena
-
A rolled-back deploy leaves its schema in the table's history: When a column addition succeeds on the table before another stack resource fails,
UPDATE_ROLLBACK_COMPLETErestorescurrent-schema-id, while the new schema stays inschemasandlast-column-idstays bumped. Treat ids from a rolled-back deploy as used.
Changes that replace or remove the table
Changing tableName, database, or catalogId replaces the table (Name, DatabaseName, and CatalogId require replacement in AWS::Glue::Table). removalPolicy (default RemovalPolicy.RETAIN) sets both DeletionPolicy and UpdateReplacePolicy: under RETAIN, CloudFormation leaves the old catalog entry in Glue outside the stack; under DESTROY, CloudFormation deletes the old catalog entry. Glue creates the replacement as a new table carrying nothing over from the old one.
When a deploy under RemovalPolicy.DESTROY changes tableName while keeping the same location, Glue creates the replacement with a new table-uuid and a 00000- metadata file at that location, Athena SELECT * returns no rows, and objects written by the old table stay under location beside that file. What a same-location replacement under RemovalPolicy.RETAIN leaves at the old location is not observed.
Give a replacement table its own location: IcebergTable never deletes S3 objects, and whether Athena VACUUM on a replacement sharing an old location treats the old table's files as orphans past vacuum_max_snapshot_age_seconds is not observed.
Is this the right tool
How it compares
| Approach | Declarative IaC (in the PR) | In-place schema + partition evolution | Keeps out the two hand-written shapes that go wrong | Typed API + synth-time validation |
|---|---|---|---|---|
Raw CfnTable (L1) |
Yes | Only if you hand-write the OpenTableFormatInput shape |
Yours to avoid | No |
| CDK custom resource (Lambda + Glue SDK) | Custom resource to maintain | Diff logic is yours to write | Your code's responsibility | No |
| Spark SQL or Athena SQL DDL at job runtime | Imperative, outside CloudFormation | Outside CloudFormation | n/a | No |
cdk-glue-iceberg-table |
Yes | Via cdk deploy |
Avoids both by construction; field-id reuse is not checked | Yes |
Why a raw CfnTable goes wrong
AWS documents Iceberg tables on AWS::Glue::Table with OpenTableFormatInput.IcebergInput (AWS Big Data blog, aws/aws-cdk#29660). The two shapes below break or fail.
Schema under storageDescriptor.columns
Glue creates the table below with parameter table_type ICEBERG, and Athena SELECT * initially returns its header. After an update that adds a column, the table has no Glue parameters and Athena SELECT * and SELECT count(*) fail with HIVE_UNSUPPORTED_FORMAT.
new CfnTable(this, 'OrdersBad', {
catalogId: this.account,
databaseName: 'analytics',
tableInput: {
name: 'orders',
tableType: 'EXTERNAL_TABLE',
storageDescriptor: {
location: 's3://.../orders/',
columns: [/* ... */],
},
},
openTableFormatInput: {
icebergInput: {
metadataOperation: 'CREATE',
version: '2',
},
},
});
IcebergTable always emits schema, partitions, sort order, and properties under openTableFormatInput.icebergInput.icebergTableInput.
tableInput beside icebergTableInput
Declaring tableInput (even holding only name) beside openTableFormatInput.icebergInput.icebergTableInput fails at creation with Table metadata is expected only via TableInput or via IcebergTableInput inside OpenTableFormatInput. IcebergTable omits tableInput and stores comment in icebergTableInput.properties['comment'].
What the construct rests on
IcebergTable relies on undocumented AWS Glue behaviors verified on v2 and v3 tables against Spark and Athena; see docs/glue-behaviours.md for the observed list.
Granting access
const table = new IcebergTable(this, 'Orders', {
// ...
encryptionKey: bucketKey, // KMS key encrypting the table's S3 bucket
});
table.grantRead(role);
table.grantWrite(role);
table.grantReadWrite(role, {
catalogEncryptionKey: catalogKey, // Glue Data Catalog SSE-KMS key
lakeFormationDataAccess: true, // Athena / Lake Formation registered locations
});
Each method emits these IAM statements and no others:
| Statement | grantRead |
grantWrite |
grantReadWrite |
Resource |
|---|---|---|---|---|
| Glue | glue:BatchGetPartition, glue:GetDatabase, glue:GetPartition, glue:GetPartitions, glue:GetTable, glue:GetTables, glue:GetTableVersion, glue:GetTableVersions |
glue:BatchCreatePartition, glue:BatchDeletePartition, glue:CreatePartition, glue:DeletePartition, glue:UpdatePartition, glue:UpdateTable |
both lists | catalog, database, and table ARNs in the stack account or catalogId |
| S3 list | s3:ListBucket |
none | s3:ListBucket |
bucket ARN with condition StringLike s3:prefix = <prefix>* or <prefix> |
| S3 bucket | s3:GetBucketLocation |
s3:ListBucketMultipartUploads |
both | bucket ARN |
| S3 objects | s3:GetObject |
s3:PutObject, s3:DeleteObject, s3:AbortMultipartUpload, s3:ListMultipartUploadParts |
both lists | <bucket>/<prefix>* |
Table key (encryptionKey) |
kms:Decrypt |
kms:Decrypt, kms:GenerateDataKey |
kms:Decrypt, kms:GenerateDataKey |
the key |
Catalog key (catalogEncryptionKey) |
kms:Decrypt |
kms:Decrypt, kms:Encrypt, kms:GenerateDataKey |
kms:Decrypt, kms:Encrypt, kms:GenerateDataKey |
the key |
Lake Formation (lakeFormationDataAccess: true) |
lakeformation:GetDataAccess |
lakeformation:GetDataAccess |
lakeformation:GetDataAccess |
* |
KMS grants apply to the whole key (IKey.grant adds no encryption-context condition), so a shared bucket or catalog key grants access for everything it encrypts. lakeformation:GetDataAccess uses * because Lake Formation supports no resource ARN for that action; the construct issues it only when lakeFormationDataAccess: true is passed, allowing the principal to call GetDataAccess for tables authorized by Lake Formation.
Lake Formation permissions (AWS::LakeFormation::Permissions) are declared separately:
import { CfnPermissions } from 'aws-cdk-lib/aws-lakeformation';
new CfnPermissions(this, 'OrdersReader', {
dataLakePrincipal: { dataLakePrincipalIdentifier: role.roleArn },
resource: {
tableResource: {
catalogId: this.account,
databaseName: table.database.databaseName,
name: table.tableName,
},
},
permissions: ['SELECT', 'DESCRIBE'], // add INSERT, DELETE, ALTER for writers
});
In Python, use encryption_key, lake_formation_data_access, and catalog_encryption_key.
CloudFormation deploying-role permissions
The IAM role deploying a stack with IcebergTable (in CDK, the CloudFormation execution role passed via iam:PassRole on bootstrap roles) needs Glue database and table permissions (CreateTable, UpdateTable, DeleteTable, GetTable, GetDatabase), S3 read/write on the table location prefix (Glue writes metadata.json there on create and update) plus KMS permissions on any bucket or catalog encryption keys, and Lake Formation admin or table/data-location permissions if Lake Formation governs the location. See docs/integ-test-setup.md for the complete IAM and Lake Formation setup used by the repository's integration stacks.
Reference
Format version 3
Set formatVersion: IcebergFormatVersion.V3 to create a v3 table. The six v3 types below are accepted only on V3 tables at any nesting depth; cdk synth rejects them on V1 or V2 tables.
import {
IcebergEdgeAlgorithm,
IcebergFormatVersion,
IcebergTable,
IcebergType,
} from 'cdk-glue-iceberg-table';
new IcebergTable(this, 'Events', {
database: db,
tableName: 'events',
location: `s3://${bucket.bucketName}/analytics/events/`,
columns: [
{ name: 'occurred_at', type: IcebergType.TIMESTAMP_NS, id: 1 },
{ name: 'payload', type: IcebergType.VARIANT, id: 2 },
{
name: 'origin',
type: IcebergType.geography('OGC:CRS84', IcebergEdgeAlgorithm.SPHERICAL),
id: 3,
},
],
formatVersion: IcebergFormatVersion.V3,
});
The same table in Python:
from cdk_glue_iceberg_table import (
IcebergColumn,
IcebergEdgeAlgorithm,
IcebergFormatVersion,
IcebergTable,
IcebergType,
)
IcebergTable(self, "Events",
database=db,
table_name="events",
location=f"s3://{bucket.bucket_name}/analytics/events/",
columns=[
IcebergColumn(name="occurred_at", type=IcebergType.TIMESTAMP_NS, id=1),
IcebergColumn(name="payload", type=IcebergType.VARIANT, id=2),
IcebergColumn(
name="origin",
type=IcebergType.geography("OGC:CRS84", IcebergEdgeAlgorithm.SPHERICAL),
id=3,
),
],
format_version=IcebergFormatVersion.V3,
)
| Type | Factory | Rendered string | Partition and identifier rules |
|---|---|---|---|
| unknown | IcebergType.UNKNOWN |
unknown |
Optional only (column, list element, or map value; never a map key). Partition source only with void. Not an identifier field. |
| timestamp_ns | IcebergType.TIMESTAMP_NS |
timestamp_ns |
identity, year, month, day, hour, bucket(N), void; not truncate(W). Allowed as an identifier field. |
| timestamptz_ns | IcebergType.TIMESTAMPTZ_NS |
timestamptz_ns |
Same as timestamp_ns. |
| variant | IcebergType.VARIANT |
variant |
Never a partition or sort source, void included. Not an identifier field. |
| geometry | IcebergType.geometry(crs?) |
geometry, or geometry(<crs>) |
Partition source only with void. Not an identifier field. |
| geography | IcebergType.geography(crs?, algorithm?) |
geography, geography(<crs>), or geography(<crs>, <algorithm>) |
Same as geometry. Setting algorithm without crs spells out OGC:CRS84. |
Geometry and geography crs values must be non-empty identifiers (such as OGC:CRS84 or EPSG:3857) with no whitespace, parentheses, braces, or commas.
| Engine | v3 tables | Notes |
|---|---|---|
| Spark 4.1.1 + Iceberg 1.11.0 | Yes | Supports deletion vectors, row lineage, variant, and unknown; cannot open timestamp_ns, timestamptz_ns, geometry, or geography (Known limitations). |
| AWS Glue 6.0 | Documented | AWS Glue release notes list Iceberg v3 (VARIANT, deletion vectors, row lineage, nanosecond timestamps, geo types); shares the Spark/Iceberg versions above (scripts/spark/spark-env.sh), while the managed Glue job runtime itself is not exercised here. |
| Amazon EMR Spark 8.1.0 | Documented | EMR Spark 8.1.0 release notes list Iceberg v3 support; not exercised here. |
| Athena SQL | No | Athena Iceberg documentation states Athena operates only on Iceberg v2 tables. |
Columns and field ids
Every top-level column takes an id, every struct field takes an id, every list takes elementId, and every map takes keyId and valueId. All ids in a schema must be distinct integers from 1 to 2147483447 (Integer.MAX_VALUE - 200, the Iceberg reserved field ids ceiling).
Creation order
Glue numbers a new table's top-level columns first in declaration order, then each column's nested fields in turn (list element; map key, map value, key's nested fields, value's nested fields; struct fields, then their nested fields). IcebergTable.creationOrderFieldIds(columns) returns this path-to-id map regardless of the ids in columns:
const columns = [
{ name: 'id', type: IcebergType.LONG, required: true, id: 1 },
{ name: 'tags', type: IcebergType.list({ element: IcebergType.STRING, elementId: 4 }), id: 2 },
{
name: 'attrs',
type: IcebergType.map({ key: IcebergType.STRING, keyId: 5, value: IcebergType.STRING, valueId: 6 }),
id: 3,
},
];
IcebergTable.creationOrderFieldIds(columns);
// { id: 1, tags: 2, attrs: 3, 'tags.element': 4, 'attrs.key': 5, 'attrs.value': 6 }
Partition fields
Each partition field declares a fieldId of 1000 or above (matching the Iceberg spec reference numbering) and an IcebergPartitionTransform. cdk synth validates fieldId >= 1000 and transform-to-column compatibility. Number a new table's partition fields 1000, 1001, and up in partitionSpec order: Glue assigns those ids at creation and ignores declared ones, whereas fields added in later updates keep their declared fieldId.
Identifier fields
identifierFieldNames lists columns that together identify a row and renders as schema.identifierFieldIds. cdk synth enforces required: true on every identifier column and rejects types float, double, list, map, struct, unknown, variant, geometry, and geography.
The construct prepends (PK) to each identifier column's doc ((PK) alone when doc is omitted), so user-supplied doc strings cannot start with (PK) . Because Glue's UpdateTable reuses an earlier schema whose fields (including doc) match the request, the marker ensures every identifier change produces a distinct schema change.
Table properties
tableProperties entries are passed to Glue as given, except format-version and write.format.default, which are populated from formatVersion and dataFormat and must agree if repeated in tableProperties. Set the table description via either comment or tableProperties['comment'], not both. For v2 or v3 merge-on-read DML, set write.delete.mode, write.update.mode, and write.merge.mode to 'merge-on-read' in tableProperties.
Adopting an existing table or migrating to raw CfnTable
Use IcebergTable.fromIcebergTableAttributes to reference an existing table for grants (grantRead, grantWrite, grantReadWrite) without managing its schema or properties in CloudFormation:
const existing = IcebergTable.fromIcebergTableAttributes(this, 'Orders', {
database: db,
tableName: 'orders',
location: 's3://my-bucket/analytics/orders/',
encryptionKey: bucketKey, // optional
catalogId: '111122223333', // optional
});
existing.grantRead(role);
To migrate an existing IcebergTable off this construct onto a raw CfnTable without replacing the Glue table, use the table.resource escape hatch (the underlying CfnTable child with construct id 'Resource', also exposed as table.node.defaultChild). Because IcebergTable nests its CfnTable under child id 'Resource', capture its CloudFormation logical ID from the synthesized template (or stack.getLogicalId(table.resource)) before removing IcebergTable, declare a CfnTable with the matching openTableFormatInput.icebergInput properties and applyRemovalPolicy(...), and pass that logical ID to raw.overrideLogicalId(logicalId):
import { RemovalPolicy } from 'aws-cdk-lib';
import { CfnTable } from 'aws-cdk-lib/aws-glue';
// Capture `logicalId` from the existing stack (`stack.getLogicalId(table.resource)`) before replacing:
const raw = new CfnTable(this, 'OrdersTable', {
catalogId: this.account,
databaseName: db.databaseName,
name: 'orders',
openTableFormatInput: { /* matching icebergInput shape */ },
});
raw.applyRemovalPolicy(RemovalPolicy.RETAIN);
raw.overrideLogicalId(logicalId);
With matching properties, removal policy, and logical ID, the synthesized AWS::Glue::Table resource is identical to what IcebergTable emits, so cdk deploy leaves the Glue table untouched.
Preventing field-id reuse in team CI
Because IcebergTable checks ids within one declaration only, teams can prevent accidental id reuse in CI by comparing each PR's synthesized AWS::Glue::Table template (Properties.OpenTableFormatInput.IcebergInput.IcebergTableInput.Schema.Fields and PartitionSpec.Fields) against the live table's metadata.json (last-column-id, historical schemas, last-partition-id, and partition-specs, read from the S3 URI in Glue's Table.Parameters.metadata_location): fail CI if any newly added column or nested field reuses an id <= last-column-id or an id previously bound to a different field path/name in schemas, or if a changed partition field reuses an existing field-id. See docs/field-ids.md for the exact aws glue get-table / aws s3 cp lookup commands.
Catalog account and tokenized table names
catalogId (catalog_id in Python) on IcebergTable and IcebergTableAttributes sets the target Glue Data Catalog account (12 digits if literal, or a CDK token). When omitted, the stack's account is used; when set, CatalogId, tableArn, and all grant database/table/catalog ARNs use that account (the database must already exist in that catalog, and cross-account catalog/Lake Formation/IAM policies remain yours to configure).
tableName accepts a lowercase [a-z0-9_]+ literal or a CDK token (such as CfnParameter or cross-stack reference). Tokens are not validated at synth time; avoid resolving tableName to *, which would widen grants across every table in the database.
Exported types
All symbols exported by cdk-glue-iceberg-table (in Python, cdk_glue_iceberg_table):
IcebergTable: the L2 construct, exposingtableArn,tableName,database,location,encryptionKey,dataFormat,formatVersion,resource(the underlyingCfnTablechild'Resource'),grantRead/grantWrite/grantReadWrite,fromIcebergTableAttributes(...), andcreationOrderFieldIds(columns)(creation_order_field_idsin Python; names containing.or ``` are backquoted).IIcebergTable: public interface implemented byIcebergTableand tables returned byfromIcebergTableAttributes.IcebergTableProps: constructor properties interface forIcebergTable.IcebergTableAttributes: attributes interface forIcebergTable.fromIcebergTableAttributes.IcebergTableGrantOptions: options interface for grant methods (lakeFormationDataAccess,catalogEncryptionKey).IcebergColumn: top-level column definition (name,type,id, optionalrequired,doc).IcebergPartitionField: partition spec entry (sourceColumn,transform,fieldId, optionalname).IcebergSortField: write-order entry (sourceColumn, optionaltransform,direction,nullOrder).IcebergType: type constants and factories (BOOLEAN,INT,LONG,FLOAT,DOUBLE,DATE,TIME,TIMESTAMP,TIMESTAMPTZ,STRING,UUID,BINARY,UNKNOWN,TIMESTAMP_NS,TIMESTAMPTZ_NS,VARIANT,decimal,fixed,list,map,struct,geometry,geography) with private constructor andkind: IcebergTypeKind.IcebergTypeKind: enum discriminator forIcebergType(for example,type.kind === IcebergTypeKind.DECIMAL).IcebergListDefinition,IcebergMapDefinition,IcebergStructFieldDefinition: nested-type definitions carrying element, key, value, and struct field ids.IcebergEdgeAlgorithm: geography edge-interpolation algorithm enum (SPHERICAL,VINCENTY,THOMAS,ANDOYER,KARNEY).IcebergPartitionTransform: transform constants and factories (IDENTITY,YEAR,MONTH,DAY,HOUR,VOID,bucket(N),truncate(W)) with private constructor,kind: IcebergPartitionTransformKind, andtoTransformString().IcebergPartitionTransformKind: enum discriminator forIcebergPartitionTransform(for example,transform.kind === IcebergPartitionTransformKind.BUCKET).IcebergDataFormat: data-file format enum (PARQUET,ORC,AVRO; defaults toPARQUET).IcebergFormatVersion: Iceberg format version enum (V1,V2,V3; required onIcebergTable).IcebergSortDirection: sort direction enum (ASC,DESC).IcebergNullOrder: null-ordering enum (NULLS_FIRST,NULLS_LAST).
Known limitations
- Creation-time numbering: Glue ignores declared column and partition ids on
CREATEand numbers columns in creation order and partition fields from1000(Creation order, Partition fields). - Stateless field-id validation:
IcebergTablechecks ids within one declaration only and cannot detect cross-deploy id reuse (The field id rules). - Merge-on-read on v1:
write.{delete,update,merge}.mode = merge-on-readis not rejected at synth onIcebergFormatVersion.V1; set it only on v2 or v3 tables. - Mixed CDK and engine partition evolution: check
last-partition-idinmetadata.jsonbefore running engine-sideALTER TABLE ... ADD PARTITION FIELDafter CDK partition updates. - Pre-0.11.0 identifier removal: tables created with identifiers before 0.11.0 lack
(PK)markers in their earliest schema, so removing the last identifier without changing another column'sdocrestores the old schema with ids. - Update mechanism: every non-replacing deploy emits
metadataOperation: 'CREATE'(the only value CloudFormation'sIcebergInputaccepts), which CloudFormation passes through Glue'sUpdateTable. - Column defaults and Athena DDL-only clauses: Iceberg v3
initial-default/write-defaultand Hive/Athena-only clauses (ALTER TABLE ... SET LOCATION,bucketed_by) are not exposed byAWS::Glue::Table(useIcebergPartitionTransform.bucket(N)). - Spark v3 type support: Spark and Iceberg at the versions listed under Format version 3 lack
TypeToSparkTypeconversion fortimestamp_ns,timestamptz_ns,geometry, andgeography(Cannot convert unsupported type to Spark), so tables with those columns are catalog-only in those runtimes.
Contributing
The package is developed in the ksco92/arceus monorepo alongside a CDK demo and integration suite. Build/test instructions, CI and release gates, and the demo stacks live in CONTRIBUTING.md.
License
MIT.
Metadata
Release files for cdk-glue-iceberg-table 0.23.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cdk_glue_iceberg_table-0.23.0.tar.gz | 179.8 kB | With provenance | Details for cdk_glue_iceberg_table-0.23.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cdk_glue_iceberg_table-0.23.0-py3-none-any.whl | Python 3 | none | any | Details for cdk_glue_iceberg_table-0.23.0-py3-none-any.whl |
Total release size: 334.5 kB
Release files / cdk_glue_iceberg_table-0.23.0.tar.gz
| Download URL | cdk_glue_iceberg_table-0.23.0.tar.gz |
|---|---|
| Size | 179.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd7b8131474edefa3b0697fefaee0586a8b2e39be9b51212f88f8fa015920ed7
|
|
BLAKE2b-256 checksum How to use checksums |
ef24275acfef4c80bf5861b0e531814e2f70cdfbe6c8de444212f7edd90de6cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / cdk_glue_iceberg_table-0.23.0-py3-none-any.whl
| Download URL | cdk_glue_iceberg_table-0.23.0-py3-none-any.whl |
|---|---|
| Size | 154.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01cc201a39c7fb42a6b5418fc215c06aab81c468ed1661387578e7bf14b3d469
|
|
BLAKE2b-256 checksum How to use checksums |
ce62af28435c7170508ef4284610dc0718bd491a880d41571c9903d32867f5dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for cdk-glue-iceberg-table 0.23.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cdk_glue_iceberg_table-0.23.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.