class Table (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.S3Tables.Alpha.Table |
![]() | software.amazon.awscdk.services.s3tables.alpha.Table |
![]() | aws_cdk.aws_s3tables_alpha.Table |
![]() | @aws-cdk/aws-s3tables-alpha ยป Table |
Implements
IConstruct
, IDependable
, IResource
, ITable
An S3 Table with helpers.
Example
// Build a table
const sampleTable = new Table(scope, 'ExampleTable', {
tableName: 'example_table',
namespace: namespace,
openTableFormat: OpenTableFormat.ICEBERG,
withoutMetadata: true,
});
// Build a table with an Iceberg Schema
const sampleTableWithSchema = new Table(scope, 'ExampleSchemaTable', {
tableName: 'example_table_with_schema',
namespace: namespace,
openTableFormat: OpenTableFormat.ICEBERG,
icebergMetadata: {
icebergSchema: {
schemaFieldList: [
{
name: 'id',
type: 'int',
required: true,
},
{
name: 'name',
type: 'string',
},
],
},
},
compaction: {
status: Status.ENABLED,
targetFileSizeMb: 128,
},
snapshotManagement: {
status: Status.ENABLED,
maxSnapshotAgeHours: 48,
minSnapshotsToKeep: 5,
},
});
Initializer
new Table(scope: Construct, id: string, props: TableProps)
Parameters
- scope
Construct
- id
string
- props
Table
Props
Construct Props
Name | Type | Description |
---|---|---|
namespace | INamespace | The namespace under which this table is created. |
open | Open | Format of this table. |
table | string | Name of this table, unique within the namespace. |
compaction? | Compaction | Settings governing the Compaction maintenance action. |
iceberg | Iceberg | Contains details about the metadata for an Iceberg table. |
removal | Removal | Controls what happens to this table it it stoped being managed by cloudformation. |
snapshot | Snapshot | Contains details about the snapshot management settings for an Iceberg table. |
without | boolean | If true, indicates that you don't want to specify a schema for the table. |
namespace
Type:
INamespace
The namespace under which this table is created.
openTableFormat
Type:
Open
Format of this table.
Currently, the only supported value is OpenTableFormat.ICEBERG.
tableName
Type:
string
Name of this table, unique within the namespace.
compaction?
Type:
Compaction
(optional, default: Amazon S3 selects the best compaction strategy based on your table sort order.)
Settings governing the Compaction maintenance action.
See also: https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-maintenance.html
icebergMetadata?
Type:
Iceberg
(optional, default: table is created without any metadata)
Contains details about the metadata for an Iceberg table.
removalPolicy?
Type:
Removal
(optional, default: RETAIN)
Controls what happens to this table it it stoped being managed by cloudformation.
snapshotManagement?
Type:
Snapshot
(optional, default: enabled: MinimumSnapshots is 1 by default and MaximumSnapshotAge is 120 hours by default.)
Contains details about the snapshot management settings for an Iceberg table.
withoutMetadata?
Type:
boolean
(optional, default: false)
If true, indicates that you don't want to specify a schema for the table.
This property is mutually exclusive to 'IcebergMetadata'.
Properties
Name | Type | Description |
---|---|---|
auto | boolean | Indicates if a table resource policy should automatically created upon the first call to addToResourcePolicy . |
env | Resource | The environment this resource belongs to. |
namespace | INamespace | The namespace containing this table. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
table | string | The unique Amazon Resource Name (arn) of this table. |
table | string | The name of this table. |
table | Cfn | The resource policy for this table. |
static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
autoCreatePolicy
Type:
boolean
Indicates if a table resource policy should automatically created upon the first call to addToResourcePolicy
.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
namespace
Type:
INamespace
The namespace containing this table.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
tableArn
Type:
string
The unique Amazon Resource Name (arn) of this table.
tableName
Type:
string
The name of this table.
tablePolicy?
Type:
Cfn
(optional)
The resource policy for this table.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
Name | Description |
---|---|
add | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this table. |
apply | Apply the given removal policy to this resource. |
grant | Grant read permissions for this table to an IAM principal (Role/Group/User). |
grant | Grant read and write permissions for this table to an IAM principal (Role/Group/User). |
grant | Grant write permissions for this table to an IAM principal (Role/Group/User). |
to | Returns a string representation of this construct. |
static from | Defines a Table construct that represents an external table. |
static validate | See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-naming.html. |
addToResourcePolicy(statement)
public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult
Parameters
- statement
Policy
Statement
Returns
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.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
grantRead(identity)
public grantRead(identity: IGrantable): Grant
Parameters
- identity
IGrantable
Returns
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.
grantReadWrite(identity)
public grantReadWrite(identity: IGrantable): Grant
Parameters
- identity
IGrantable
Returns
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.
grantWrite(identity)
public grantWrite(identity: IGrantable): Grant
Parameters
- identity
IGrantable
Returns
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.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromTableAttributes(scope, id, attrs)
public static fromTableAttributes(scope: Construct, id: string, attrs: TableAttributes): ITable
Parameters
- scope
Construct
โ The parent creating construct (usuallythis
). - id
string
โ The construct's name. - attrs
Table
โ AAttributes TableAttributes
object containing the table name and ARN.
Returns
Defines a Table construct that represents an external table.
static validateTableName(tableName)
public static validateTableName(tableName: string): void
Parameters
- tableName
string
โ Name of the table.
See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-naming.html.