1. Packages
  2. AWS
  3. API Docs
  4. dynamodb
  5. GlobalTable
AWS v6.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

aws.dynamodb.GlobalTable

Explore with Pulumi AI

Manages DynamoDB Global Tables V1 (version 2017.11.29). These are layered on top of existing DynamoDB Tables.

NOTE: To instead manage DynamoDB Global Tables V2 (version 2019.11.21), use the aws.dynamodb.Table resource replica configuration block.

Note: There are many restrictions before you can properly create DynamoDB Global Tables in multiple regions. See the AWS DynamoDB Global Table Requirements for more information.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const us_east_1 = new aws.dynamodb.Table("us-east-1", {
    hashKey: "myAttribute",
    name: "myTable",
    streamEnabled: true,
    streamViewType: "NEW_AND_OLD_IMAGES",
    readCapacity: 1,
    writeCapacity: 1,
    attributes: [{
        name: "myAttribute",
        type: "S",
    }],
});
const us_west_2 = new aws.dynamodb.Table("us-west-2", {
    hashKey: "myAttribute",
    name: "myTable",
    streamEnabled: true,
    streamViewType: "NEW_AND_OLD_IMAGES",
    readCapacity: 1,
    writeCapacity: 1,
    attributes: [{
        name: "myAttribute",
        type: "S",
    }],
});
const myTable = new aws.dynamodb.GlobalTable("myTable", {
    name: "myTable",
    replicas: [
        {
            regionName: "us-east-1",
        },
        {
            regionName: "us-west-2",
        },
    ],
}, {
    dependsOn: [
        us_east_1,
        us_west_2,
    ],
});
Copy
import pulumi
import pulumi_aws as aws

us_east_1 = aws.dynamodb.Table("us-east-1",
    hash_key="myAttribute",
    name="myTable",
    stream_enabled=True,
    stream_view_type="NEW_AND_OLD_IMAGES",
    read_capacity=1,
    write_capacity=1,
    attributes=[{
        "name": "myAttribute",
        "type": "S",
    }])
us_west_2 = aws.dynamodb.Table("us-west-2",
    hash_key="myAttribute",
    name="myTable",
    stream_enabled=True,
    stream_view_type="NEW_AND_OLD_IMAGES",
    read_capacity=1,
    write_capacity=1,
    attributes=[{
        "name": "myAttribute",
        "type": "S",
    }])
my_table = aws.dynamodb.GlobalTable("myTable",
    name="myTable",
    replicas=[
        {
            "region_name": "us-east-1",
        },
        {
            "region_name": "us-west-2",
        },
    ],
    opts = pulumi.ResourceOptions(depends_on=[
            us_east_1,
            us_west_2,
        ]))
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		us_east_1, err := dynamodb.NewTable(ctx, "us-east-1", &dynamodb.TableArgs{
			HashKey:        pulumi.String("myAttribute"),
			Name:           pulumi.String("myTable"),
			StreamEnabled:  pulumi.Bool(true),
			StreamViewType: pulumi.String("NEW_AND_OLD_IMAGES"),
			ReadCapacity:   pulumi.Int(1),
			WriteCapacity:  pulumi.Int(1),
			Attributes: dynamodb.TableAttributeArray{
				&dynamodb.TableAttributeArgs{
					Name: pulumi.String("myAttribute"),
					Type: pulumi.String("S"),
				},
			},
		})
		if err != nil {
			return err
		}
		us_west_2, err := dynamodb.NewTable(ctx, "us-west-2", &dynamodb.TableArgs{
			HashKey:        pulumi.String("myAttribute"),
			Name:           pulumi.String("myTable"),
			StreamEnabled:  pulumi.Bool(true),
			StreamViewType: pulumi.String("NEW_AND_OLD_IMAGES"),
			ReadCapacity:   pulumi.Int(1),
			WriteCapacity:  pulumi.Int(1),
			Attributes: dynamodb.TableAttributeArray{
				&dynamodb.TableAttributeArgs{
					Name: pulumi.String("myAttribute"),
					Type: pulumi.String("S"),
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = dynamodb.NewGlobalTable(ctx, "myTable", &dynamodb.GlobalTableArgs{
			Name: pulumi.String("myTable"),
			Replicas: dynamodb.GlobalTableReplicaArray{
				&dynamodb.GlobalTableReplicaArgs{
					RegionName: pulumi.String("us-east-1"),
				},
				&dynamodb.GlobalTableReplicaArgs{
					RegionName: pulumi.String("us-west-2"),
				},
			},
		}, pulumi.DependsOn([]pulumi.Resource{
			us_east_1,
			us_west_2,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var us_east_1 = new Aws.DynamoDB.Table("us-east-1", new()
    {
        HashKey = "myAttribute",
        Name = "myTable",
        StreamEnabled = true,
        StreamViewType = "NEW_AND_OLD_IMAGES",
        ReadCapacity = 1,
        WriteCapacity = 1,
        Attributes = new[]
        {
            new Aws.DynamoDB.Inputs.TableAttributeArgs
            {
                Name = "myAttribute",
                Type = "S",
            },
        },
    });

    var us_west_2 = new Aws.DynamoDB.Table("us-west-2", new()
    {
        HashKey = "myAttribute",
        Name = "myTable",
        StreamEnabled = true,
        StreamViewType = "NEW_AND_OLD_IMAGES",
        ReadCapacity = 1,
        WriteCapacity = 1,
        Attributes = new[]
        {
            new Aws.DynamoDB.Inputs.TableAttributeArgs
            {
                Name = "myAttribute",
                Type = "S",
            },
        },
    });

    var myTable = new Aws.DynamoDB.GlobalTable("myTable", new()
    {
        Name = "myTable",
        Replicas = new[]
        {
            new Aws.DynamoDB.Inputs.GlobalTableReplicaArgs
            {
                RegionName = "us-east-1",
            },
            new Aws.DynamoDB.Inputs.GlobalTableReplicaArgs
            {
                RegionName = "us-west-2",
            },
        },
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            us_east_1,
            us_west_2,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.dynamodb.Table;
import com.pulumi.aws.dynamodb.TableArgs;
import com.pulumi.aws.dynamodb.inputs.TableAttributeArgs;
import com.pulumi.aws.dynamodb.GlobalTable;
import com.pulumi.aws.dynamodb.GlobalTableArgs;
import com.pulumi.aws.dynamodb.inputs.GlobalTableReplicaArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var us_east_1 = new Table("us-east-1", TableArgs.builder()
            .hashKey("myAttribute")
            .name("myTable")
            .streamEnabled(true)
            .streamViewType("NEW_AND_OLD_IMAGES")
            .readCapacity(1)
            .writeCapacity(1)
            .attributes(TableAttributeArgs.builder()
                .name("myAttribute")
                .type("S")
                .build())
            .build());

        var us_west_2 = new Table("us-west-2", TableArgs.builder()
            .hashKey("myAttribute")
            .name("myTable")
            .streamEnabled(true)
            .streamViewType("NEW_AND_OLD_IMAGES")
            .readCapacity(1)
            .writeCapacity(1)
            .attributes(TableAttributeArgs.builder()
                .name("myAttribute")
                .type("S")
                .build())
            .build());

        var myTable = new GlobalTable("myTable", GlobalTableArgs.builder()
            .name("myTable")
            .replicas(            
                GlobalTableReplicaArgs.builder()
                    .regionName("us-east-1")
                    .build(),
                GlobalTableReplicaArgs.builder()
                    .regionName("us-west-2")
                    .build())
            .build(), CustomResourceOptions.builder()
                .dependsOn(                
                    us_east_1,
                    us_west_2)
                .build());

    }
}
Copy
resources:
  us-east-1:
    type: aws:dynamodb:Table
    properties:
      hashKey: myAttribute
      name: myTable
      streamEnabled: true
      streamViewType: NEW_AND_OLD_IMAGES
      readCapacity: 1
      writeCapacity: 1
      attributes:
        - name: myAttribute
          type: S
  us-west-2:
    type: aws:dynamodb:Table
    properties:
      hashKey: myAttribute
      name: myTable
      streamEnabled: true
      streamViewType: NEW_AND_OLD_IMAGES
      readCapacity: 1
      writeCapacity: 1
      attributes:
        - name: myAttribute
          type: S
  myTable:
    type: aws:dynamodb:GlobalTable
    properties:
      name: myTable
      replicas:
        - regionName: us-east-1
        - regionName: us-west-2
    options:
      dependsOn:
        - ${["us-east-1"]}
        - ${["us-west-2"]}
Copy

Create GlobalTable Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new GlobalTable(name: string, args: GlobalTableArgs, opts?: CustomResourceOptions);
@overload
def GlobalTable(resource_name: str,
                args: GlobalTableArgs,
                opts: Optional[ResourceOptions] = None)

@overload
def GlobalTable(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                replicas: Optional[Sequence[GlobalTableReplicaArgs]] = None,
                name: Optional[str] = None)
func NewGlobalTable(ctx *Context, name string, args GlobalTableArgs, opts ...ResourceOption) (*GlobalTable, error)
public GlobalTable(string name, GlobalTableArgs args, CustomResourceOptions? opts = null)
public GlobalTable(String name, GlobalTableArgs args)
public GlobalTable(String name, GlobalTableArgs args, CustomResourceOptions options)
type: aws:dynamodb:GlobalTable
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. GlobalTableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. GlobalTableArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. GlobalTableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. GlobalTableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. GlobalTableArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var globalTableResource = new Aws.DynamoDB.GlobalTable("globalTableResource", new()
{
    Replicas = new[]
    {
        new Aws.DynamoDB.Inputs.GlobalTableReplicaArgs
        {
            RegionName = "string",
        },
    },
    Name = "string",
});
Copy
example, err := dynamodb.NewGlobalTable(ctx, "globalTableResource", &dynamodb.GlobalTableArgs{
	Replicas: dynamodb.GlobalTableReplicaArray{
		&dynamodb.GlobalTableReplicaArgs{
			RegionName: pulumi.String("string"),
		},
	},
	Name: pulumi.String("string"),
})
Copy
var globalTableResource = new GlobalTable("globalTableResource", GlobalTableArgs.builder()
    .replicas(GlobalTableReplicaArgs.builder()
        .regionName("string")
        .build())
    .name("string")
    .build());
Copy
global_table_resource = aws.dynamodb.GlobalTable("globalTableResource",
    replicas=[{
        "region_name": "string",
    }],
    name="string")
Copy
const globalTableResource = new aws.dynamodb.GlobalTable("globalTableResource", {
    replicas: [{
        regionName: "string",
    }],
    name: "string",
});
Copy
type: aws:dynamodb:GlobalTable
properties:
    name: string
    replicas:
        - regionName: string
Copy

GlobalTable Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The GlobalTable resource accepts the following input properties:

Replicas This property is required. List<GlobalTableReplica>
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
Name Changes to this property will trigger replacement. string
The name of the global table. Must match underlying DynamoDB Table names in all regions.
Replicas This property is required. []GlobalTableReplicaArgs
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
Name Changes to this property will trigger replacement. string
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas This property is required. List<GlobalTableReplica>
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
name Changes to this property will trigger replacement. String
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas This property is required. GlobalTableReplica[]
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
name Changes to this property will trigger replacement. string
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas This property is required. Sequence[GlobalTableReplicaArgs]
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
name Changes to this property will trigger replacement. str
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas This property is required. List<Property Map>
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
name Changes to this property will trigger replacement. String
The name of the global table. Must match underlying DynamoDB Table names in all regions.

Outputs

All input properties are implicitly available as output properties. Additionally, the GlobalTable resource produces the following output properties:

Arn string
The ARN of the DynamoDB Global Table
Id string
The provider-assigned unique ID for this managed resource.
Arn string
The ARN of the DynamoDB Global Table
Id string
The provider-assigned unique ID for this managed resource.
arn String
The ARN of the DynamoDB Global Table
id String
The provider-assigned unique ID for this managed resource.
arn string
The ARN of the DynamoDB Global Table
id string
The provider-assigned unique ID for this managed resource.
arn str
The ARN of the DynamoDB Global Table
id str
The provider-assigned unique ID for this managed resource.
arn String
The ARN of the DynamoDB Global Table
id String
The provider-assigned unique ID for this managed resource.

Look up Existing GlobalTable Resource

Get an existing GlobalTable resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: GlobalTableState, opts?: CustomResourceOptions): GlobalTable
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        name: Optional[str] = None,
        replicas: Optional[Sequence[GlobalTableReplicaArgs]] = None) -> GlobalTable
func GetGlobalTable(ctx *Context, name string, id IDInput, state *GlobalTableState, opts ...ResourceOption) (*GlobalTable, error)
public static GlobalTable Get(string name, Input<string> id, GlobalTableState? state, CustomResourceOptions? opts = null)
public static GlobalTable get(String name, Output<String> id, GlobalTableState state, CustomResourceOptions options)
resources:  _:    type: aws:dynamodb:GlobalTable    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Arn string
The ARN of the DynamoDB Global Table
Name Changes to this property will trigger replacement. string
The name of the global table. Must match underlying DynamoDB Table names in all regions.
Replicas List<GlobalTableReplica>
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
Arn string
The ARN of the DynamoDB Global Table
Name Changes to this property will trigger replacement. string
The name of the global table. Must match underlying DynamoDB Table names in all regions.
Replicas []GlobalTableReplicaArgs
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
arn String
The ARN of the DynamoDB Global Table
name Changes to this property will trigger replacement. String
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas List<GlobalTableReplica>
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
arn string
The ARN of the DynamoDB Global Table
name Changes to this property will trigger replacement. string
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas GlobalTableReplica[]
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
arn str
The ARN of the DynamoDB Global Table
name Changes to this property will trigger replacement. str
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas Sequence[GlobalTableReplicaArgs]
Underlying DynamoDB Table. At least 1 replica must be defined. See below.
arn String
The ARN of the DynamoDB Global Table
name Changes to this property will trigger replacement. String
The name of the global table. Must match underlying DynamoDB Table names in all regions.
replicas List<Property Map>
Underlying DynamoDB Table. At least 1 replica must be defined. See below.

Supporting Types

GlobalTableReplica
, GlobalTableReplicaArgs

RegionName This property is required. string
AWS region name of replica DynamoDB TableE.g., us-east-1
RegionName This property is required. string
AWS region name of replica DynamoDB TableE.g., us-east-1
regionName This property is required. String
AWS region name of replica DynamoDB TableE.g., us-east-1
regionName This property is required. string
AWS region name of replica DynamoDB TableE.g., us-east-1
region_name This property is required. str
AWS region name of replica DynamoDB TableE.g., us-east-1
regionName This property is required. String
AWS region name of replica DynamoDB TableE.g., us-east-1

Import

Using pulumi import, import DynamoDB Global Tables using the global table name. For example:

$ pulumi import aws:dynamodb/globalTable:GlobalTable MyTable MyTable
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.