@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
581 lines (580 loc) • 24.8 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* Provides a DynamoDB table resource.
*
* > **Note:** It is recommended to use [`ignoreChanges`](https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges) for `readCapacity` and/or `writeCapacity` if there's `autoscaling policy` attached to the table.
*
* > **Note:** When using aws.dynamodb.TableReplica with this resource, use `lifecycle` `ignoreChanges` for `replica`, _e.g._, `lifecycle { ignoreChanges = [replica] }`.
*
* ## DynamoDB Table attributes
*
* Only define attributes on the table object that are going to be used as:
*
* * Table hash key or range key
* * LSI or GSI hash key or range key
*
* The DynamoDB API expects attribute structure (name and type) to be passed along when creating or updating GSI/LSIs or creating the initial table. In these cases it expects the Hash / Range keys to be provided. Because these get re-used in numerous places (i.e the table's range key could be a part of one or more GSIs), they are stored on the table object to prevent duplication and increase consistency. If you add attributes here that are not used in these scenarios it can cause an infinite loop in planning.
*
* ## Example Usage
*
* ### Basic Example
*
* The following dynamodb table description models the table and GSI shown in the [AWS SDK example documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const basic_dynamodb_table = new aws.dynamodb.Table("basic-dynamodb-table", {
* name: "GameScores",
* billingMode: "PROVISIONED",
* readCapacity: 20,
* writeCapacity: 20,
* hashKey: "UserId",
* rangeKey: "GameTitle",
* attributes: [
* {
* name: "UserId",
* type: "S",
* },
* {
* name: "GameTitle",
* type: "S",
* },
* {
* name: "TopScore",
* type: "N",
* },
* ],
* ttl: {
* attributeName: "TimeToExist",
* enabled: true,
* },
* globalSecondaryIndexes: [{
* name: "GameTitleIndex",
* hashKey: "GameTitle",
* rangeKey: "TopScore",
* writeCapacity: 10,
* readCapacity: 10,
* projectionType: "INCLUDE",
* nonKeyAttributes: ["UserId"],
* }],
* tags: {
* Name: "dynamodb-table-1",
* Environment: "production",
* },
* });
* ```
*
* ### Global Tables
*
* This resource implements support for [DynamoDB Global Tables V2 (version 2019.11.21)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html) via `replica` configuration blocks. For working with [DynamoDB Global Tables V1 (version 2017.11.29)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V1.html), see the `aws.dynamodb.GlobalTable` resource.
*
* > **Note:** aws.dynamodb.TableReplica is an alternate way of configuring Global Tables. Do not use `replica` configuration blocks of `aws.dynamodb.Table` together with aws_dynamodb_table_replica.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.dynamodb.Table("example", {
* name: "example",
* hashKey: "TestTableHashKey",
* billingMode: "PAY_PER_REQUEST",
* streamEnabled: true,
* streamViewType: "NEW_AND_OLD_IMAGES",
* attributes: [{
* name: "TestTableHashKey",
* type: "S",
* }],
* replicas: [
* {
* regionName: "us-east-2",
* },
* {
* regionName: "us-west-2",
* },
* ],
* });
* ```
*
* ### Global Tables with Multi-Region Strong Consistency
*
* A global table configured for Multi-Region strong consistency (MRSC) provides the ability to perform a strongly consistent read with multi-Region scope. Performing a strongly consistent read on an MRSC table ensures you're always reading the latest version of an item, irrespective of the Region in which you're performing the read.
*
* **Note** Please see detailed information, restrictions, caveats etc on the [AWS Support Page](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/multi-region-strong-consistency-gt.html).
*
* Consistency Mode (`consistencyMode`) is a new argument on the embedded `replica` that allows you to configure consistency mode for Global Tables.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.dynamodb.Table("example", {
* name: "example",
* hashKey: "TestTableHashKey",
* billingMode: "PAY_PER_REQUEST",
* streamEnabled: true,
* streamViewType: "NEW_AND_OLD_IMAGES",
* attributes: [{
* name: "TestTableHashKey",
* type: "S",
* }],
* replicas: [
* {
* regionName: "us-east-2",
* consistencyMode: "STRONG",
* },
* {
* regionName: "us-west-2",
* consistencyMode: "STRONG",
* },
* ],
* });
* ```
*
* ### Replica Tagging
*
* You can manage global table replicas' tags in various ways. This example shows using `replica.*.propagate_tags` for the first replica and the `aws.dynamodb.Tag` resource for the other.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const current = aws.getRegion({});
* const alternate = aws.getRegion({});
* const third = aws.getRegion({});
* const example = new aws.dynamodb.Table("example", {
* billingMode: "PAY_PER_REQUEST",
* hashKey: "TestTableHashKey",
* name: "example-13281",
* streamEnabled: true,
* streamViewType: "NEW_AND_OLD_IMAGES",
* attributes: [{
* name: "TestTableHashKey",
* type: "S",
* }],
* replicas: [
* {
* regionName: alternate.then(alternate => alternate.name),
* },
* {
* regionName: third.then(third => third.name),
* propagateTags: true,
* },
* ],
* tags: {
* Architect: "Eleanor",
* Zone: "SW",
* },
* });
* const exampleTag = new aws.dynamodb.Tag("example", {
* resourceArn: pulumi.all([example.arn, current, alternate]).apply(([arn, current, alternate]) => std.replaceOutput({
* text: arn,
* search: current.region,
* replace: alternate.name,
* })).apply(invoke => invoke.result),
* key: "Architect",
* value: "Gigi",
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import DynamoDB tables using the `name`. For example:
*
* ```sh
* $ pulumi import aws:dynamodb/table:Table basic-dynamodb-table GameScores
* ```
*/
export declare class Table extends pulumi.CustomResource {
/**
* Get an existing Table resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: TableState, opts?: pulumi.CustomResourceOptions): Table;
/**
* Returns true if the given object is an instance of Table. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is Table;
/**
* ARN of the table
*/
readonly arn: pulumi.Output<string>;
/**
* Set of nested attribute definitions. Only required for `hashKey` and `rangeKey` attributes. See below.
*/
readonly attributes: pulumi.Output<outputs.dynamodb.TableAttribute[]>;
/**
* Controls how you are charged for read and write throughput and how you manage capacity. The valid values are `PROVISIONED` and `PAY_PER_REQUEST`. Defaults to `PROVISIONED`.
*/
readonly billingMode: pulumi.Output<string | undefined>;
/**
* Enables deletion protection for table. Defaults to `false`.
*/
readonly deletionProtectionEnabled: pulumi.Output<boolean | undefined>;
/**
* Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc. See below.
*/
readonly globalSecondaryIndexes: pulumi.Output<outputs.dynamodb.TableGlobalSecondaryIndex[] | undefined>;
/**
* Attribute to use as the hash (partition) key. Must also be defined as an `attribute`. See below.
*/
readonly hashKey: pulumi.Output<string>;
/**
* Import Amazon S3 data into a new table. See below.
*/
readonly importTable: pulumi.Output<outputs.dynamodb.TableImportTable | undefined>;
/**
* Describe an LSI on the table; these can only be allocated _at creation_ so you cannot change this definition after you have created the resource. See below.
*/
readonly localSecondaryIndexes: pulumi.Output<outputs.dynamodb.TableLocalSecondaryIndex[] | undefined>;
/**
* Unique within a region name of the table.
*
* The following arguments are optional:
*/
readonly name: pulumi.Output<string>;
/**
* Sets the maximum number of read and write units for the specified on-demand table. See below.
*/
readonly onDemandThroughput: pulumi.Output<outputs.dynamodb.TableOnDemandThroughput | undefined>;
/**
* Enable point-in-time recovery options. See below.
*/
readonly pointInTimeRecovery: pulumi.Output<outputs.dynamodb.TablePointInTimeRecovery>;
/**
* Attribute to use as the range (sort) key. Must also be defined as an `attribute`, see below.
*/
readonly rangeKey: pulumi.Output<string | undefined>;
/**
* Number of read units for this table. If the `billingMode` is `PROVISIONED`, this field is required.
*/
readonly readCapacity: pulumi.Output<number>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
readonly region: pulumi.Output<string>;
/**
* Configuration block(s) with [DynamoDB Global Tables V2 (version 2019.11.21)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html) replication configurations. See below.
*/
readonly replicas: pulumi.Output<outputs.dynamodb.TableReplica[] | undefined>;
/**
* Time of the point-in-time recovery point to restore.
*/
readonly restoreDateTime: pulumi.Output<string | undefined>;
/**
* Name of the table to restore. Must match the name of an existing table.
*/
readonly restoreSourceName: pulumi.Output<string | undefined>;
/**
* ARN of the source table to restore. Must be supplied for cross-region restores.
*/
readonly restoreSourceTableArn: pulumi.Output<string | undefined>;
/**
* If set, restores table to the most recent point-in-time recovery point.
*/
readonly restoreToLatestTime: pulumi.Output<boolean | undefined>;
/**
* Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS-owned Customer Master Key if this argument isn't specified. Must be supplied for cross-region restores. See below.
*/
readonly serverSideEncryption: pulumi.Output<outputs.dynamodb.TableServerSideEncryption>;
/**
* ARN of the Table Stream. Only available when `streamEnabled = true`
*/
readonly streamArn: pulumi.Output<string>;
/**
* Whether Streams are enabled.
*/
readonly streamEnabled: pulumi.Output<boolean | undefined>;
/**
* Timestamp, in ISO 8601 format, for this stream. Note that this timestamp is not a unique identifier for the stream on its own. However, the combination of AWS customer ID, table name and this field is guaranteed to be unique. It can be used for creating CloudWatch Alarms. Only available when `streamEnabled = true`.
*/
readonly streamLabel: pulumi.Output<string>;
/**
* When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values are `KEYS_ONLY`, `NEW_IMAGE`, `OLD_IMAGE`, `NEW_AND_OLD_IMAGES`.
*/
readonly streamViewType: pulumi.Output<string>;
/**
* Storage class of the table.
* Valid values are `STANDARD` and `STANDARD_INFREQUENT_ACCESS`.
* Default value is `STANDARD`.
*/
readonly tableClass: pulumi.Output<string | undefined>;
/**
* A map of tags to populate on the created table. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
*/
readonly tags: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
*/
readonly tagsAll: pulumi.Output<{
[key: string]: string;
}>;
/**
* Configuration block for TTL. See below.
*/
readonly ttl: pulumi.Output<outputs.dynamodb.TableTtl>;
/**
* Number of write units for this table. If the `billingMode` is `PROVISIONED`, this field is required.
*/
readonly writeCapacity: pulumi.Output<number>;
/**
* Create a Table resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: TableArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Table resources.
*/
export interface TableState {
/**
* ARN of the table
*/
arn?: pulumi.Input<string>;
/**
* Set of nested attribute definitions. Only required for `hashKey` and `rangeKey` attributes. See below.
*/
attributes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableAttribute>[]>;
/**
* Controls how you are charged for read and write throughput and how you manage capacity. The valid values are `PROVISIONED` and `PAY_PER_REQUEST`. Defaults to `PROVISIONED`.
*/
billingMode?: pulumi.Input<string>;
/**
* Enables deletion protection for table. Defaults to `false`.
*/
deletionProtectionEnabled?: pulumi.Input<boolean>;
/**
* Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc. See below.
*/
globalSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableGlobalSecondaryIndex>[]>;
/**
* Attribute to use as the hash (partition) key. Must also be defined as an `attribute`. See below.
*/
hashKey?: pulumi.Input<string>;
/**
* Import Amazon S3 data into a new table. See below.
*/
importTable?: pulumi.Input<inputs.dynamodb.TableImportTable>;
/**
* Describe an LSI on the table; these can only be allocated _at creation_ so you cannot change this definition after you have created the resource. See below.
*/
localSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableLocalSecondaryIndex>[]>;
/**
* Unique within a region name of the table.
*
* The following arguments are optional:
*/
name?: pulumi.Input<string>;
/**
* Sets the maximum number of read and write units for the specified on-demand table. See below.
*/
onDemandThroughput?: pulumi.Input<inputs.dynamodb.TableOnDemandThroughput>;
/**
* Enable point-in-time recovery options. See below.
*/
pointInTimeRecovery?: pulumi.Input<inputs.dynamodb.TablePointInTimeRecovery>;
/**
* Attribute to use as the range (sort) key. Must also be defined as an `attribute`, see below.
*/
rangeKey?: pulumi.Input<string>;
/**
* Number of read units for this table. If the `billingMode` is `PROVISIONED`, this field is required.
*/
readCapacity?: pulumi.Input<number>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* Configuration block(s) with [DynamoDB Global Tables V2 (version 2019.11.21)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html) replication configurations. See below.
*/
replicas?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableReplica>[]>;
/**
* Time of the point-in-time recovery point to restore.
*/
restoreDateTime?: pulumi.Input<string>;
/**
* Name of the table to restore. Must match the name of an existing table.
*/
restoreSourceName?: pulumi.Input<string>;
/**
* ARN of the source table to restore. Must be supplied for cross-region restores.
*/
restoreSourceTableArn?: pulumi.Input<string>;
/**
* If set, restores table to the most recent point-in-time recovery point.
*/
restoreToLatestTime?: pulumi.Input<boolean>;
/**
* Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS-owned Customer Master Key if this argument isn't specified. Must be supplied for cross-region restores. See below.
*/
serverSideEncryption?: pulumi.Input<inputs.dynamodb.TableServerSideEncryption>;
/**
* ARN of the Table Stream. Only available when `streamEnabled = true`
*/
streamArn?: pulumi.Input<string>;
/**
* Whether Streams are enabled.
*/
streamEnabled?: pulumi.Input<boolean>;
/**
* Timestamp, in ISO 8601 format, for this stream. Note that this timestamp is not a unique identifier for the stream on its own. However, the combination of AWS customer ID, table name and this field is guaranteed to be unique. It can be used for creating CloudWatch Alarms. Only available when `streamEnabled = true`.
*/
streamLabel?: pulumi.Input<string>;
/**
* When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values are `KEYS_ONLY`, `NEW_IMAGE`, `OLD_IMAGE`, `NEW_AND_OLD_IMAGES`.
*/
streamViewType?: pulumi.Input<string>;
/**
* Storage class of the table.
* Valid values are `STANDARD` and `STANDARD_INFREQUENT_ACCESS`.
* Default value is `STANDARD`.
*/
tableClass?: pulumi.Input<string>;
/**
* A map of tags to populate on the created table. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
*/
tags?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
*/
tagsAll?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* Configuration block for TTL. See below.
*/
ttl?: pulumi.Input<inputs.dynamodb.TableTtl>;
/**
* Number of write units for this table. If the `billingMode` is `PROVISIONED`, this field is required.
*/
writeCapacity?: pulumi.Input<number>;
}
/**
* The set of arguments for constructing a Table resource.
*/
export interface TableArgs {
/**
* Set of nested attribute definitions. Only required for `hashKey` and `rangeKey` attributes. See below.
*/
attributes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableAttribute>[]>;
/**
* Controls how you are charged for read and write throughput and how you manage capacity. The valid values are `PROVISIONED` and `PAY_PER_REQUEST`. Defaults to `PROVISIONED`.
*/
billingMode?: pulumi.Input<string>;
/**
* Enables deletion protection for table. Defaults to `false`.
*/
deletionProtectionEnabled?: pulumi.Input<boolean>;
/**
* Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc. See below.
*/
globalSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableGlobalSecondaryIndex>[]>;
/**
* Attribute to use as the hash (partition) key. Must also be defined as an `attribute`. See below.
*/
hashKey?: pulumi.Input<string>;
/**
* Import Amazon S3 data into a new table. See below.
*/
importTable?: pulumi.Input<inputs.dynamodb.TableImportTable>;
/**
* Describe an LSI on the table; these can only be allocated _at creation_ so you cannot change this definition after you have created the resource. See below.
*/
localSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableLocalSecondaryIndex>[]>;
/**
* Unique within a region name of the table.
*
* The following arguments are optional:
*/
name?: pulumi.Input<string>;
/**
* Sets the maximum number of read and write units for the specified on-demand table. See below.
*/
onDemandThroughput?: pulumi.Input<inputs.dynamodb.TableOnDemandThroughput>;
/**
* Enable point-in-time recovery options. See below.
*/
pointInTimeRecovery?: pulumi.Input<inputs.dynamodb.TablePointInTimeRecovery>;
/**
* Attribute to use as the range (sort) key. Must also be defined as an `attribute`, see below.
*/
rangeKey?: pulumi.Input<string>;
/**
* Number of read units for this table. If the `billingMode` is `PROVISIONED`, this field is required.
*/
readCapacity?: pulumi.Input<number>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* Configuration block(s) with [DynamoDB Global Tables V2 (version 2019.11.21)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html) replication configurations. See below.
*/
replicas?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableReplica>[]>;
/**
* Time of the point-in-time recovery point to restore.
*/
restoreDateTime?: pulumi.Input<string>;
/**
* Name of the table to restore. Must match the name of an existing table.
*/
restoreSourceName?: pulumi.Input<string>;
/**
* ARN of the source table to restore. Must be supplied for cross-region restores.
*/
restoreSourceTableArn?: pulumi.Input<string>;
/**
* If set, restores table to the most recent point-in-time recovery point.
*/
restoreToLatestTime?: pulumi.Input<boolean>;
/**
* Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS-owned Customer Master Key if this argument isn't specified. Must be supplied for cross-region restores. See below.
*/
serverSideEncryption?: pulumi.Input<inputs.dynamodb.TableServerSideEncryption>;
/**
* Whether Streams are enabled.
*/
streamEnabled?: pulumi.Input<boolean>;
/**
* When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values are `KEYS_ONLY`, `NEW_IMAGE`, `OLD_IMAGE`, `NEW_AND_OLD_IMAGES`.
*/
streamViewType?: pulumi.Input<string>;
/**
* Storage class of the table.
* Valid values are `STANDARD` and `STANDARD_INFREQUENT_ACCESS`.
* Default value is `STANDARD`.
*/
tableClass?: pulumi.Input<string>;
/**
* A map of tags to populate on the created table. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
*/
tags?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* Configuration block for TTL. See below.
*/
ttl?: pulumi.Input<inputs.dynamodb.TableTtl>;
/**
* Number of write units for this table. If the `billingMode` is `PROVISIONED`, this field is required.
*/
writeCapacity?: pulumi.Input<number>;
}