1. Packages
  2. AWS Classic
  3. API Docs
  4. dynamodb
  5. GlobalTable

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi

aws.dynamodb.GlobalTable

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi

    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,
        ],
    });
    
    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=[aws.dynamodb.TableAttributeArgs(
            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=[aws.dynamodb.TableAttributeArgs(
            name="myAttribute",
            type="S",
        )])
    my_table = aws.dynamodb.GlobalTable("myTable",
        name="myTable",
        replicas=[
            aws.dynamodb.GlobalTableReplicaArgs(
                region_name="us-east-1",
            ),
            aws.dynamodb.GlobalTableReplicaArgs(
                region_name="us-west-2",
            ),
        ],
        opts=pulumi.ResourceOptions(depends_on=[
                us_east_1,
                us_west_2,
            ]))
    
    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 {
    		_, 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
    		}
    		_, 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
    	})
    }
    
    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, 
            },
        });
    
    });
    
    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());
    
        }
    }
    
    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"]}
    

    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 string
    The unique name of the resource.
    args GlobalTableArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args GlobalTableArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GlobalTableArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GlobalTableArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    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",
    });
    
    example, err := dynamodb.NewGlobalTable(ctx, "globalTableResource", &dynamodb.GlobalTableArgs{
    	Replicas: dynamodb.GlobalTableReplicaArray{
    		&dynamodb.GlobalTableReplicaArgs{
    			RegionName: pulumi.String("string"),
    		},
    	},
    	Name: pulumi.String("string"),
    })
    
    var globalTableResource = new GlobalTable("globalTableResource", GlobalTableArgs.builder()        
        .replicas(GlobalTableReplicaArgs.builder()
            .regionName("string")
            .build())
        .name("string")
        .build());
    
    global_table_resource = aws.dynamodb.GlobalTable("globalTableResource",
        replicas=[aws.dynamodb.GlobalTableReplicaArgs(
            region_name="string",
        )],
        name="string")
    
    const globalTableResource = new aws.dynamodb.GlobalTable("globalTableResource", {
        replicas: [{
            regionName: "string",
        }],
        name: "string",
    });
    
    type: aws:dynamodb:GlobalTable
    properties:
        name: string
        replicas:
            - regionName: string
    

    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

    The GlobalTable resource accepts the following input properties:

    Replicas List<Pulumi.Aws.DynamoDB.Inputs.GlobalTableReplica>
    Underlying DynamoDB Table. At least 1 replica must be defined. See below.
    Name 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.
    Name 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.
    name 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.
    name string
    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.
    name str
    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.
    name 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    The name of the global table. Must match underlying DynamoDB Table names in all regions.
    Replicas List<Pulumi.Aws.DynamoDB.Inputs.GlobalTableReplica>
    Underlying DynamoDB Table. At least 1 replica must be defined. See below.
    Arn string
    The ARN of the DynamoDB Global Table
    Name 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 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 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 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 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 string
    AWS region name of replica DynamoDB TableE.g., us-east-1
    RegionName string
    AWS region name of replica DynamoDB TableE.g., us-east-1
    regionName String
    AWS region name of replica DynamoDB TableE.g., us-east-1
    regionName string
    AWS region name of replica DynamoDB TableE.g., us-east-1
    region_name str
    AWS region name of replica DynamoDB TableE.g., us-east-1
    regionName 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
    

    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.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi