import * as iam from 'aws-cdk-lib/aws-iam'; import { CfnTablePolicy } from 'aws-cdk-lib/aws-s3tables'; import type { IResource, ITaggableV2, RemovalPolicy, TagManager } from 'aws-cdk-lib/core'; import { Resource } from 'aws-cdk-lib/core'; import type { Construct } from 'constructs'; import type { INamespace } from './namespace'; import type { StorageClass } from './table-bucket'; /** * Represents an S3 Table. */ export interface ITable extends IResource { /** * The ARN of this table. * @attribute */ readonly tableArn: string; /** * The name of this table. * @attribute */ readonly tableName: string; /** * The accountId containing this table. * @attribute */ readonly account?: string; /** * The region containing this table. * @attribute */ readonly region?: string; /** * Adds a statement to the resource policy for a principal (i.e. * account/role/service) to perform actions on this table. * * Note that the policy statement may or may not be added to the policy. * For example, when an `ITable` is created from an existing table, * it's not possible to tell whether the table already has a policy * attached, let alone to re-use that policy to add more statements to it. * So it's safest to do nothing in these cases. * * @param statement the policy statement to be added to the table's * policy. * @returns metadata about the execution of this method. If the policy * was not added, the value of `statementAdded` will be `false`. You * should always check this value to make sure that the operation was * actually carried out. Otherwise, synthesis and deploy will terminate * silently, which may be confusing. */ addToResourcePolicy(statement: iam.PolicyStatement): iam.AddToResourcePolicyResult; /** * Grant read permissions for this table to an IAM principal (Role/Group/User). * * If the parent TableBucket of this table has encryption, * you should grant kms:Decrypt permission to use this key to the same principal. * * @param identity The principal to allow read permissions to */ grantRead(identity: iam.IGrantable): iam.Grant; /** * Grant write permissions for this table to an IAM principal (Role/Group/User). * * If the parent TableBucket of this table has encryption, * you should grant kms:GenerateDataKey and kms:Decrypt permission * to use this key to the same principal. * * @param identity The principal to allow write permissions to */ grantWrite(identity: iam.IGrantable): iam.Grant; /** * Grant read and write permissions for this table to an IAM principal (Role/Group/User). * * If the parent TableBucket of this table has encryption, * you should grant kms:GenerateDataKey and kms:Decrypt permission * to use this key to the same principal. * * @param identity The principal to allow read and write permissions to */ grantReadWrite(identity: iam.IGrantable): iam.Grant; } /** * Base class for Table implementations. */ declare abstract class TableBase extends Resource implements ITable { abstract readonly tableName: string; abstract readonly tableArn: string; /** * The resource policy associated with this table. * * If `autoCreatePolicy` is true, a `TablePolicy` will be created upon the * first call to addToResourcePolicy(s). */ abstract tablePolicy?: CfnTablePolicy; /** * Indicates if a table resource policy should automatically created upon * the first call to `addToResourcePolicy`. */ protected abstract autoCreatePolicy: boolean; addToResourcePolicy(statement: iam.PolicyStatement): iam.AddToResourcePolicyResult; /** * [disable-awslint:no-grants] */ grantRead(identity: iam.IGrantable): iam.Grant; /** * [disable-awslint:no-grants] */ grantWrite(identity: iam.IGrantable): iam.Grant; /** * [disable-awslint:no-grants] */ grantReadWrite(identity: iam.IGrantable): iam.Grant; /** * Grants the given s3tables permissions to the provided principal * @returns Grant object */ private grant; } /** * Properties for creating a new S3 Table. */ export interface TableProps { /** * Name of this table, unique within the namespace */ readonly tableName: string; /** * The namespace under which this table is created */ readonly namespace: INamespace; /** * Format of this table. Currently, the only supported value is OpenTableFormat.ICEBERG. */ readonly openTableFormat: OpenTableFormat; /** * Settings governing the Compaction maintenance action. * @default Amazon S3 selects the best compaction strategy based on your table sort order. * @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-maintenance.html */ readonly compaction?: CompactionProperty; /** * Contains details about the metadata for an Iceberg table. * @default table is created without any metadata */ readonly icebergMetadata?: IcebergMetadataProperty; /** * Contains details about the snapshot management settings for an Iceberg table. * @default enabled: MinimumSnapshots is 1 by default and MaximumSnapshotAge is 120 hours by default. */ readonly snapshotManagement?: SnapshotManagementProperty; /** * Controls what happens to this table it it stoped being managed by cloudformation. * * @default RETAIN */ readonly removalPolicy?: RemovalPolicy; /** * If true, indicates that you don't want to specify a schema for the table. * * This property is mutually exclusive to 'IcebergMetadata'. * * @default false */ readonly withoutMetadata?: boolean; /** * The storage class for the table. * * Determines the storage tier used for table data, allowing optimization * for different access patterns and cost profiles. * * Note: This is a create-only property and cannot be changed after the table is created. * * @default - Inherits from the table bucket's storage class configuration */ readonly storageClass?: StorageClass; } /** * Supported open table formats. */ export declare enum OpenTableFormat { /** * Apache Iceberg table format. */ ICEBERG = "ICEBERG" } /** * Settings governing the Compaction maintenance action. * * @default - No compaction settings */ export interface CompactionProperty { /** * Status of the compaction maintenance action. */ readonly status: Status; /** * Target file size in megabytes for compaction. */ readonly targetFileSizeMb: number; } /** * Status values for maintenance actions. */ export declare enum Status { /** * Enable the maintenance action. */ ENABLED = "enabled", /** * Disable the maintenance action. */ DISABLED = "disabled" } /** * Iceberg transform values for partition and sort fields. */ export declare class IcebergTransform { /** * Use the column value as the transform value without transformation. */ static readonly IDENTITY: IcebergTransform; /** * Transform a timestamp/date field to year. */ static readonly YEAR: IcebergTransform; /** * Transform a timestamp/date field to month. */ static readonly MONTH: IcebergTransform; /** * Transform a timestamp/date field to day. */ static readonly DAY: IcebergTransform; /** * Transform a timestamp field to hour. */ static readonly HOUR: IcebergTransform; /** * Transform values into a fixed number of buckets. * * @param n The number of buckets (must be a positive integer) */ static bucket(n: number): IcebergTransform; /** * Truncate values to a fixed width. * * @param width The truncation width (must be a positive integer) */ static truncate(width: number): IcebergTransform; /** * Create a custom transform from a string value. * * @param value The transform string value */ static of(value: string): IcebergTransform; /** * The string value of the transform. */ readonly value: string; private constructor(); /** * Returns the string representation of the transform. */ toString(): string; } /** * Sort direction values for Iceberg sort fields. */ export declare enum SortDirection { /** * Sort values in ascending order. */ ASC = "asc", /** * Sort values in descending order. */ DESC = "desc" } /** * Null ordering values for Iceberg sort fields. */ export declare enum NullOrder { /** * Place null values before non-null values. */ NULLS_FIRST = "nulls-first", /** * Place null values after non-null values. */ NULLS_LAST = "nulls-last" } /** * Partition field definition for Iceberg table. * * Defines a single partition column. Multiple partition fields can be combined * in an IcebergPartitionSpec to create multi-level partitioning. */ export interface IcebergPartitionField { /** * The source field ID from the schema. */ readonly sourceId: number; /** * The partition transform function. * * Use `IcebergTransform` static properties for common transforms (e.g., `IcebergTransform.IDENTITY`) * or methods for parameterized transforms (e.g., `IcebergTransform.bucket(16)`). */ readonly transform: IcebergTransform; /** * The name of the partition field. */ readonly name: string; /** * The unique identifier for the partition field. * * @default - Auto-assigned starting from 1000 */ readonly fieldId?: number; } /** * Partition specification for Iceberg table. * * Contains the complete partitioning configuration for a table, including all partition fields. * Use this to define multi-level partitioning (e.g., partition by date, then by region). */ export interface IcebergPartitionSpec { /** * The list of partition fields. */ readonly fields: IcebergPartitionField[]; /** * The unique identifier for the partition specification. * * @default 0 */ readonly specId?: number; } /** * Sort field definition for Iceberg table. */ export interface IcebergSortField { /** * The source field ID from the schema. */ readonly sourceId: number; /** * The sort transform function. * * Use `IcebergTransform` static properties for common transforms (e.g., `IcebergTransform.IDENTITY`) * or methods for parameterized transforms (e.g., `IcebergTransform.bucket(16)`). */ readonly transform: IcebergTransform; /** * The sort direction. */ readonly direction: SortDirection; /** * The null ordering. */ readonly nullOrder: NullOrder; } /** * Sort order specification for Iceberg table. */ export interface IcebergSortOrder { /** * The list of sort fields. */ readonly fields: IcebergSortField[]; /** * The unique identifier for the sort order. * * @default 1 */ readonly orderId?: number; } /** * A single table property key-value pair for Iceberg table configuration. */ export interface TablePropertyEntry { /** * The property key. */ readonly key: string; /** * The property value. */ readonly value: string; } /** * Contains details about the metadata for an Iceberg table. * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3tables-table-icebergmetadata.html */ export interface IcebergMetadataProperty { /** * Contains details about the schema for an Iceberg table. * * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3tables-table-icebergmetadata.html#cfn-s3tables-table-icebergmetadata-icebergschema */ readonly icebergSchema: IcebergSchemaProperty; /** * The partition specification for the Iceberg table. * * @default - No partition specification */ readonly icebergPartitionSpec?: IcebergPartitionSpec; /** * The sort order for the Iceberg table. * * @default - No sort order */ readonly icebergSortOrder?: IcebergSortOrder; /** * Custom properties for the Iceberg table. * Each entry represents a key-value pair for Iceberg table configuration. * * @default - No custom properties */ readonly tableProperties?: TablePropertyEntry[]; } /** * Contains details about the schema for an Iceberg table. */ export interface IcebergSchemaProperty { /** * Contains details about the schema for an Iceberg table. */ readonly schemaFieldList: SchemaFieldProperty[]; } /** * Contains details about a schema field. */ export interface SchemaFieldProperty { /** * The unique identifier for the field. * * @default - Auto-assigned by S3 Tables */ readonly id?: number; /** * The name of the field. */ readonly name: string; /** * A Boolean value that specifies whether values are required for each row in this field. * * By default, this is `false` and null values are allowed in the field. If this is `true`, the field does not allow null values. * * @default false */ readonly required?: boolean; /** * The field type. * * S3 Tables supports all Apache Iceberg primitive types. For more information, see the [Apache Iceberg documentation](https://iceberg.apache.org/spec/#primitive-types). */ readonly type: string; } /** * Contains details about the snapshot management settings for an Iceberg table. * * A snapshot is expired when it exceeds MinSnapshotsToKeep and MaxSnapshotAgeHours. * * @default - No snapshot management settings */ export interface SnapshotManagementProperty { /** * The maximum age of a snapshot before it can be expired. * * @default - No maximum age */ readonly maxSnapshotAgeHours?: number; /** * The minimum number of snapshots to keep. * * @default - No minimum number */ readonly minSnapshotsToKeep?: number; /** * Indicates whether the SnapshotManagement maintenance action is enabled. * * @default - Not specified */ readonly status?: Status; } /** * A reference to a table outside this stack * * The tableName, region, and account can be provided explicitly * or will be inferred from the tableArn */ export interface TableAttributes { /** * Name of this table */ readonly tableName: string; /** * The table's ARN. */ readonly tableArn: string; } /** * An S3 Table with helpers. */ export declare class Table extends TableBase implements ITaggableV2 { /** Uniquely identifies this class. */ static readonly PROPERTY_INJECTION_ID: string; /** * Defines a Table construct that represents an external table. * * @param scope The parent creating construct (usually `this`). * @param id The construct's name. * @param attrs A `TableAttributes` object containing the table name and ARN. */ static fromTableAttributes(scope: Construct, id: string, attrs: TableAttributes): ITable; /** * See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-naming.html * @param tableName Name of the table * @throws UnscopedValidationError if any naming errors are detected */ static validateTableName(tableName: string): void; /** * The unique Amazon Resource Name (arn) of this table */ readonly tableArn: string; /** * The underlying CfnTable L1 resource * @internal */ private readonly _resource; /** * The tag manager for this resource. */ readonly cdkTagManager: TagManager; /** * The name of this table */ readonly tableName: string; /** * The namespace containing this table */ readonly namespace: INamespace; /** * The resource policy for this table. */ readonly tablePolicy?: CfnTablePolicy; protected autoCreatePolicy: boolean; constructor(scope: Construct, id: string, props: TableProps); /** * Builds the CloudFormation Iceberg metadata property from the CDK metadata model. */ private buildIcebergMetadata; /** * Builds the CloudFormation Iceberg schema property. */ private buildIcebergSchema; /** * Builds the CloudFormation Iceberg partition specification property. */ private buildIcebergPartitionSpec; /** * Builds the CloudFormation Iceberg sort order property. */ private buildIcebergSortOrder; /** * Builds the CloudFormation table properties map from key-value entries. */ private buildTableProperties; } export {};