Manages DynamoDB Global Tables V1 (version 2017.11.29). These are layered on top of existing DynamoDB Tables.
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
}
provider "aws" {
alias = "us-west-2"
region = "us-west-2"
}
resource "aws_dynamodb_table" "us-east-1" {
provider = aws.us-east-1
hash_key = "myAttribute"
name = "myTable"
stream_enabled = true
stream_view_type = "NEW_AND_OLD_IMAGES"
read_capacity = 1
write_capacity = 1
attribute {
name = "myAttribute"
type = "S"
}
}
resource "aws_dynamodb_table" "us-west-2" {
provider = aws.us-west-2
hash_key = "myAttribute"
name = "myTable"
stream_enabled = true
stream_view_type = "NEW_AND_OLD_IMAGES"
read_capacity = 1
write_capacity = 1
attribute {
name = "myAttribute"
type = "S"
}
}
resource "aws_dynamodb_global_table" "myTable" {
depends_on = [
aws_dynamodb_table.us-east-1,
aws_dynamodb_table.us-west-2,
]
provider = aws.us-east-1
name = "myTable"
replica {
region_name = "us-east-1"
}
replica {
region_name = "us-west-2"
}
}
This resource supports the following arguments:
name
- (Required) The name of the global table. Must match underlying DynamoDB Table names in all regions.replica
- (Required) Underlying DynamoDB Table. At least 1 replica must be defined. See below.replica
region_name
- (Required) AWS region name of replica DynamoDB TableE.g., us-east-1
This resource exports the following attributes in addition to the arguments above:
id
- The name of the DynamoDB Global Tablearn
- The ARN of the DynamoDB Global TableIn Terraform v1.5.0 and later, use an import
block to import DynamoDB Global Tables using the global table name. For example:
import {
to = aws_dynamodb_global_table.MyTable
id = "MyTable"
}
Using terraform import
, import DynamoDB Global Tables using the global table name. For example:
% terraform import aws_dynamodb_global_table.MyTable MyTable