class Table (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Glue.Table |
![]() | software.amazon.awscdk.services.glue.Table |
![]() | aws_cdk.aws_glue.Table |
![]() | @aws-cdk/aws-glue ยป Table |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, ITable
A Glue table.
Example
declare const myDatabase: glue.Database;
new glue.Table(this, 'MyTable', {
database: myDatabase,
tableName: 'my_table',
columns: [{
name: 'col1',
type: glue.Schema.STRING,
}],
partitionKeys: [{
name: 'year',
type: glue.Schema.SMALL_INT,
}, {
name: 'month',
type: glue.Schema.SMALL_INT,
}],
dataFormat: glue.DataFormat.JSON,
});
Initializer
new Table(scope: Construct, id: string, props: TableProps)
Parameters
- scope
Construct
- id
string
- props
Table
Props
Construct Props
Name | Type | Description |
---|---|---|
columns | Column [] | Columns of the table. |
data | Data | Storage type of the table's data. |
database | IDatabase | Database in which to store the table. |
table | string | Name of the table. |
bucket? | IBucket | S3 bucket in which to store data. |
compressed? | boolean | Indicates whether the table's data is compressed or not. |
description? | string | Description of the table. |
encryption? | Table | The kind of encryption to secure the data with. |
encryption | IKey | External KMS key to use for bucket encryption. |
partition | Partition [] | Partition indexes on the table. |
partition | Column [] | Partition columns of the table. |
s3 | string | S3 prefix under which table objects are stored. |
stored | boolean | Indicates whether the table data is stored in subdirectories. |
columns
Type:
Column
[]
Columns of the table.
dataFormat
Type:
Data
Storage type of the table's data.
database
Type:
IDatabase
Database in which to store the table.
tableName
Type:
string
Name of the table.
bucket?
Type:
IBucket
(optional, default: one is created for you)
S3 bucket in which to store data.
compressed?
Type:
boolean
(optional, default: false)
Indicates whether the table's data is compressed or not.
description?
Type:
string
(optional, default: generated)
Description of the table.
encryption?
Type:
Table
(optional, default: Unencrypted)
The kind of encryption to secure the data with.
You can only provide this option if you are not explicitly passing in a bucket.
If you choose SSE-KMS
, you can provide an un-managed KMS key with encryptionKey
.
If you choose CSE-KMS
, you must provide an un-managed KMS key with encryptionKey
.
encryptionKey?
Type:
IKey
(optional, default: key is managed by KMS.)
External KMS key to use for bucket encryption.
The encryption
property must be SSE-KMS
or CSE-KMS
.
partitionIndexes?
Type:
Partition
[]
(optional, default: table has no partition indexes)
Partition indexes on the table.
A maximum of 3 indexes are allowed on a table. Keys in the index must be part of the table's partition keys.
partitionKeys?
Type:
Column
[]
(optional, default: table is not partitioned)
Partition columns of the table.
s3Prefix?
Type:
string
(optional, default: No prefix. The data will be stored under the root of the bucket.)
S3 prefix under which table objects are stored.
storedAsSubDirectories?
Type:
boolean
(optional, default: false)
Indicates whether the table data is stored in subdirectories.
Properties
Name | Type | Description |
---|---|---|
bucket | IBucket | S3 bucket in which the table's data resides. |
columns | Column [] | This table's columns. |
compressed | boolean | Indicates whether the table's data is compressed or not. |
data | Data | Format of this table's data files. |
database | IDatabase | Database this table belongs to. |
encryption | Table | The type of encryption enabled for the table. |
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
s3 | string | S3 Key Prefix under which this table's files are stored in S3. |
stack | Stack | The stack in which this resource is defined. |
table | string | ARN of this table. |
table | string | Name of this table. |
encryption | IKey | The KMS key used to secure the data if encryption is set to CSE-KMS or SSE-KMS . |
partition | Partition [] | This table's partition indexes. |
partition | Column [] | This table's partition keys if the table is partitioned. |
bucket
Type:
IBucket
S3 bucket in which the table's data resides.
columns
Type:
Column
[]
This table's columns.
compressed
Type:
boolean
Indicates whether the table's data is compressed or not.
dataFormat
Type:
Data
Format of this table's data files.
database
Type:
IDatabase
Database this table belongs to.
encryption
Type:
Table
The type of encryption enabled for the table.
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.
node
Type:
Construct
The construct tree node associated with this construct.
s3Prefix
Type:
string
S3 Key Prefix under which this table's files are stored in S3.
stack
Type:
Stack
The stack in which this resource is defined.
tableArn
Type:
string
ARN of this table.
tableName
Type:
string
Name of this table.
encryptionKey?
Type:
IKey
(optional)
The KMS key used to secure the data if encryption
is set to CSE-KMS
or SSE-KMS
.
Otherwise, undefined
.
partitionIndexes?
Type:
Partition
[]
(optional)
This table's partition indexes.
partitionKeys?
Type:
Column
[]
(optional)
This table's partition keys if the table is partitioned.
Methods
Name | Description |
---|---|
add | Add a partition index to the table. |
apply | Apply the given removal policy to this resource. |
grant(grantee, actions) | Grant the given identity custom permissions. |
grant | Grant read permissions to the table and the underlying data stored in S3 to an IAM principal. |
grant | Grant read and write permissions to the table and the underlying data stored in S3 to an IAM principal. |
grant | Grant the given identity custom permissions to ALL underlying resources of the table. |
grant | Grant write permissions to the table and the underlying data stored in S3 to an IAM principal. |
to | Returns a string representation of this construct. |
static from | |
static from | Creates a Table construct that represents an external table. |
addPartitionIndex(index)
public addPartitionIndex(index: PartitionIndex): void
Parameters
- index
Partition
Index
Add a partition index to the table.
You can have a maximum of 3 partition indexes to a table. Partition index keys must be a subset of the table's partition keys.
See also: https://docs.aws.amazon.com/glue/latest/dg/partition-indexes.html
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
).
grant(grantee, actions)
public grant(grantee: IGrantable, actions: string[]): Grant
Parameters
- grantee
IGrantable
- actions
string[]
Returns
Grant the given identity custom permissions.
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
โ the principal.
Returns
Grant read permissions to the table and the underlying data stored in S3 to an IAM principal.
grantReadWrite(grantee)
public grantReadWrite(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
โ the principal.
Returns
Grant read and write permissions to the table and the underlying data stored in S3 to an IAM principal.
grantToUnderlyingResources(grantee, actions)
public grantToUnderlyingResources(grantee: IGrantable, actions: string[]): Grant
Parameters
- grantee
IGrantable
- actions
string[]
Returns
Grant the given identity custom permissions to ALL underlying resources of the table.
Permissions will be granted to the catalog, the database, and the table.
grantWrite(grantee)
public grantWrite(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
โ the principal.
Returns
Grant write permissions to the table and the underlying data stored in S3 to an IAM principal.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromTableArn(scope, id, tableArn)
public static fromTableArn(scope: Construct, id: string, tableArn: string): ITable
Parameters
- scope
Construct
- id
string
- tableArn
string
Returns
static fromTableAttributes(scope, id, attrs)
public static fromTableAttributes(scope: Construct, id: string, attrs: TableAttributes): ITable
Parameters
- scope
Construct
โ The scope creating construct (usuallythis
). - id
string
โ The construct's id. - attrs
Table
โ Import attributes.Attributes
Returns
Creates a Table construct that represents an external table.