ExternalTable

class aws_cdk.aws_glue.ExternalTable(scope, id, *, connection, external_data_location, columns, database, data_format, compressed=None, description=None, enable_partition_filtering=None, has_encrypted_data=None, parameters=None, partition_indexes=None, partition_keys=None, partition_projection=None, storage_parameters=None, stored_as_sub_directories=None, table_name=None)

Bases: TableBase

A Glue table that targets an external data location (e.g. A table in a Redshift Cluster).

Resource:

AWS::Glue::Table

ExampleMetadata:

infused

Example:

# my_connection: glue.Connection
# my_database: glue.Database

glue.ExternalTable(self, "MyTable",
    connection=my_connection,
    external_data_location="default_db_public_example",  # A table in Redshift
    # ...
    database=my_database,
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.JSON
)
Parameters:
  • scope (Construct)

  • id (str)

  • connection (IConnection) – The connection the table will use when performing reads and writes.

  • external_data_location (str) – The data source location of the glue table, (e.g. default_db_public_example for Redshift). This overrides both bucket and s3Prefix.

  • columns (Sequence[Union[Column, Dict[str, Any]]]) – Columns of the table.

  • database (IDatabase) – Database in which to store the table.

  • data_format (DataFormat) – Storage type of the table’s data.

  • compressed (Optional[bool]) – Indicates whether the table’s data is compressed or not. Default: false

  • description (Optional[str]) – Description of the table. Default: generated

  • enable_partition_filtering (Optional[bool]) – Enables partition filtering. Default: - The parameter is not defined

  • has_encrypted_data (Optional[bool]) – Whether the data stored in the table is encrypted. This sets the has_encrypted_data table parameter. Athena reads it when querying client-side (CSE-KMS) encrypted datasets; for server-side encrypted (SSE-S3 / SSE-KMS) or unencrypted data it has no effect, since Amazon S3 decrypts server-side encrypted objects transparently. Do not also set has_encrypted_data through parameters - use this property instead. A conflicting value in parameters is rejected. Default: true

  • parameters (Optional[Mapping[str, str]]) – The key/value pairs define properties associated with the table. The key/value pairs that are allowed to be submitted are not limited, however their functionality is not guaranteed. Default: - The parameter is not defined

  • partition_indexes (Optional[Sequence[Union[PartitionIndex, Dict[str, Any]]]]) – 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. Default: table has no partition indexes

  • partition_keys (Optional[Sequence[Union[Column, Dict[str, Any]]]]) – Partition columns of the table. Default: table is not partitioned

  • partition_projection (Optional[Mapping[str, PartitionProjectionConfiguration]]) – Partition projection configuration for this table. Partition projection allows Athena to automatically add new partitions without requiring ALTER TABLE ADD PARTITION statements. Default: - No partition projection

  • storage_parameters (Optional[Sequence[StorageParameter]]) – The user-supplied properties for the description of the physical storage of this table. These properties help describe the format of the data that is stored within the crawled data sources. The key/value pairs that are allowed to be submitted are not limited, however their functionality is not guaranteed. Some keys will be auto-populated by glue crawlers, however, you can override them by specifying the key and value in this property. Default: - The parameter is not defined

  • stored_as_sub_directories (Optional[bool]) – Indicates whether the table data is stored in subdirectories. Default: false

  • table_name (Optional[str]) – Name of the table. Default: - generated by CDK.

Methods

add_partition_index(*, key_names, index_name=None)

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.

Parameters:
  • key_names (Sequence[str]) – The partition key names that comprise the partition index. The names must correspond to a name in the table’s partition keys.

  • index_name (Optional[str]) – The name of the partition index. Default: - a name will be generated for you.

See:

https://docs.aws.amazon.com/glue/latest/dg/partition-indexes.html

Return type:

None

apply_cross_stack_reference_strength(strength)

Override the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the “deadly embrace” problem without changing the app-wide default.

Parameters:

strength (ReferenceStrength) –

  • The reference strength to use for this resource.

Return type:

None

apply_removal_policy(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).

Parameters:

policy (RemovalPolicy)

Return type:

None

grant(grantee, actions)

Grant the given identity custom permissions on this table.

This is a low-level escape hatch: the actions are applied verbatim, scoped to this table’s ARN. Prefer the intent-based grantRead / grantWrite / grantReadWrite methods, which grant a curated set of actions and also cover the underlying S3 data. Only pass the specific actions the grantee needs - avoid service wildcards such as glue:*. [disable-awslint:no-grants]

Parameters:
  • grantee (IGrantable) – the principal.

  • actions (Sequence[str]) – the set of Glue actions to allow (for example glue:GetTable).

Return type:

Grant

grant_read(grantee)

Grant read permissions to the table [disable-awslint:no-grants].

Parameters:

grantee (IGrantable) – the principal.

Return type:

Grant

grant_read_write(grantee)

Grant read and write permissions to the table [disable-awslint:no-grants].

Parameters:

grantee (IGrantable) – the principal.

Return type:

Grant

grant_to_underlying_resources(grantee, actions)

Grant the given identity custom permissions on this table AND its parent catalog and database.

This is a low-level escape hatch for actions (such as certain Lake Formation or crawler operations) that must be authorized against the catalog and database in addition to the table. The actions are applied verbatim to all three ARNs (table, catalog, database), so scope them tightly: pass only the specific actions the grantee needs and avoid service wildcards such as glue:*, which would grant broad access across every resource in the catalog and database. [disable-awslint:no-grants]

Parameters:
  • grantee (IGrantable) – the principal.

  • actions (Sequence[str]) – the set of Glue actions to allow (for example glue:GetTable).

Return type:

Grant

grant_write(grantee)

Grant write permissions to the table [disable-awslint:no-grants].

Parameters:

grantee (IGrantable) – the principal.

Return type:

Grant

to_string()

Returns a string representation of this construct.

Return type:

str

with_(*mixins)

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

mixins (IMixin)

Return type:

IConstruct

Attributes

PROPERTY_INJECTION_ID = '@aws-cdk.aws-glue-alpha.ExternalTable'
columns

This table’s columns.

compressed

Indicates whether the table’s data is compressed or not.

connection

The connection associated to this table.

data_format

Format of this table’s data files.

database

Database this table belongs to.

env

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

node

The tree node.

partition_indexes

This table’s partition indexes.

partition_keys

This table’s partition keys if the table is partitioned.

partition_projection

This table’s partition projection configuration if enabled.

stack

The stack in which this resource is defined.

storage_parameters

The tables’ storage descriptor properties.

table_arn

ARN of this table.

table_name

Name of this table.

Static Methods

classmethod from_table_arn(scope, id, table_arn)
Parameters:
Return type:

ITable

classmethod from_table_attributes(scope, id, *, table_arn, table_name)

Creates a Table construct that represents an external table.

Parameters:
  • scope (Construct) – The scope creating construct (usually this).

  • id (str) – The construct’s id.

  • table_arn (str)

  • table_name (str)

Return type:

ITable

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct)

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct)

Return type:

bool