github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/dynamodb/globalTable.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package dynamodb
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Manages [DynamoDB Global Tables V1 (version 2017.11.29)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V1.html). These are layered on top of existing DynamoDB Tables.
    16  //
    17  // > **NOTE:** To instead manage [DynamoDB Global Tables V2 (version 2019.11.21)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html), use the `dynamodb.Table` resource `replica` configuration block.
    18  //
    19  // > Note: There are many restrictions before you can properly create DynamoDB Global Tables in multiple regions. See the [AWS DynamoDB Global Table Requirements](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables_reqs_bestpractices.html) for more information.
    20  //
    21  // ## Example Usage
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			_, err := dynamodb.NewTable(ctx, "us-east-1", &dynamodb.TableArgs{
    37  //				HashKey:        pulumi.String("myAttribute"),
    38  //				Name:           pulumi.String("myTable"),
    39  //				StreamEnabled:  pulumi.Bool(true),
    40  //				StreamViewType: pulumi.String("NEW_AND_OLD_IMAGES"),
    41  //				ReadCapacity:   pulumi.Int(1),
    42  //				WriteCapacity:  pulumi.Int(1),
    43  //				Attributes: dynamodb.TableAttributeArray{
    44  //					&dynamodb.TableAttributeArgs{
    45  //						Name: pulumi.String("myAttribute"),
    46  //						Type: pulumi.String("S"),
    47  //					},
    48  //				},
    49  //			})
    50  //			if err != nil {
    51  //				return err
    52  //			}
    53  //			_, err = dynamodb.NewTable(ctx, "us-west-2", &dynamodb.TableArgs{
    54  //				HashKey:        pulumi.String("myAttribute"),
    55  //				Name:           pulumi.String("myTable"),
    56  //				StreamEnabled:  pulumi.Bool(true),
    57  //				StreamViewType: pulumi.String("NEW_AND_OLD_IMAGES"),
    58  //				ReadCapacity:   pulumi.Int(1),
    59  //				WriteCapacity:  pulumi.Int(1),
    60  //				Attributes: dynamodb.TableAttributeArray{
    61  //					&dynamodb.TableAttributeArgs{
    62  //						Name: pulumi.String("myAttribute"),
    63  //						Type: pulumi.String("S"),
    64  //					},
    65  //				},
    66  //			})
    67  //			if err != nil {
    68  //				return err
    69  //			}
    70  //			_, err = dynamodb.NewGlobalTable(ctx, "myTable", &dynamodb.GlobalTableArgs{
    71  //				Name: pulumi.String("myTable"),
    72  //				Replicas: dynamodb.GlobalTableReplicaArray{
    73  //					&dynamodb.GlobalTableReplicaArgs{
    74  //						RegionName: pulumi.String("us-east-1"),
    75  //					},
    76  //					&dynamodb.GlobalTableReplicaArgs{
    77  //						RegionName: pulumi.String("us-west-2"),
    78  //					},
    79  //				},
    80  //			}, pulumi.DependsOn([]pulumi.Resource{
    81  //				us_east_1,
    82  //				us_west_2,
    83  //			}))
    84  //			if err != nil {
    85  //				return err
    86  //			}
    87  //			return nil
    88  //		})
    89  //	}
    90  //
    91  // ```
    92  // <!--End PulumiCodeChooser -->
    93  //
    94  // ## Import
    95  //
    96  // Using `pulumi import`, import DynamoDB Global Tables using the global table name. For example:
    97  //
    98  // ```sh
    99  // $ pulumi import aws:dynamodb/globalTable:GlobalTable MyTable MyTable
   100  // ```
   101  type GlobalTable struct {
   102  	pulumi.CustomResourceState
   103  
   104  	// The ARN of the DynamoDB Global Table
   105  	Arn pulumi.StringOutput `pulumi:"arn"`
   106  	// The name of the global table. Must match underlying DynamoDB Table names in all regions.
   107  	Name pulumi.StringOutput `pulumi:"name"`
   108  	// Underlying DynamoDB Table. At least 1 replica must be defined. See below.
   109  	Replicas GlobalTableReplicaArrayOutput `pulumi:"replicas"`
   110  }
   111  
   112  // NewGlobalTable registers a new resource with the given unique name, arguments, and options.
   113  func NewGlobalTable(ctx *pulumi.Context,
   114  	name string, args *GlobalTableArgs, opts ...pulumi.ResourceOption) (*GlobalTable, error) {
   115  	if args == nil {
   116  		return nil, errors.New("missing one or more required arguments")
   117  	}
   118  
   119  	if args.Replicas == nil {
   120  		return nil, errors.New("invalid value for required argument 'Replicas'")
   121  	}
   122  	opts = internal.PkgResourceDefaultOpts(opts)
   123  	var resource GlobalTable
   124  	err := ctx.RegisterResource("aws:dynamodb/globalTable:GlobalTable", name, args, &resource, opts...)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	return &resource, nil
   129  }
   130  
   131  // GetGlobalTable gets an existing GlobalTable resource's state with the given name, ID, and optional
   132  // state properties that are used to uniquely qualify the lookup (nil if not required).
   133  func GetGlobalTable(ctx *pulumi.Context,
   134  	name string, id pulumi.IDInput, state *GlobalTableState, opts ...pulumi.ResourceOption) (*GlobalTable, error) {
   135  	var resource GlobalTable
   136  	err := ctx.ReadResource("aws:dynamodb/globalTable:GlobalTable", name, id, state, &resource, opts...)
   137  	if err != nil {
   138  		return nil, err
   139  	}
   140  	return &resource, nil
   141  }
   142  
   143  // Input properties used for looking up and filtering GlobalTable resources.
   144  type globalTableState struct {
   145  	// The ARN of the DynamoDB Global Table
   146  	Arn *string `pulumi:"arn"`
   147  	// The name of the global table. Must match underlying DynamoDB Table names in all regions.
   148  	Name *string `pulumi:"name"`
   149  	// Underlying DynamoDB Table. At least 1 replica must be defined. See below.
   150  	Replicas []GlobalTableReplica `pulumi:"replicas"`
   151  }
   152  
   153  type GlobalTableState struct {
   154  	// The ARN of the DynamoDB Global Table
   155  	Arn pulumi.StringPtrInput
   156  	// The name of the global table. Must match underlying DynamoDB Table names in all regions.
   157  	Name pulumi.StringPtrInput
   158  	// Underlying DynamoDB Table. At least 1 replica must be defined. See below.
   159  	Replicas GlobalTableReplicaArrayInput
   160  }
   161  
   162  func (GlobalTableState) ElementType() reflect.Type {
   163  	return reflect.TypeOf((*globalTableState)(nil)).Elem()
   164  }
   165  
   166  type globalTableArgs struct {
   167  	// The name of the global table. Must match underlying DynamoDB Table names in all regions.
   168  	Name *string `pulumi:"name"`
   169  	// Underlying DynamoDB Table. At least 1 replica must be defined. See below.
   170  	Replicas []GlobalTableReplica `pulumi:"replicas"`
   171  }
   172  
   173  // The set of arguments for constructing a GlobalTable resource.
   174  type GlobalTableArgs struct {
   175  	// The name of the global table. Must match underlying DynamoDB Table names in all regions.
   176  	Name pulumi.StringPtrInput
   177  	// Underlying DynamoDB Table. At least 1 replica must be defined. See below.
   178  	Replicas GlobalTableReplicaArrayInput
   179  }
   180  
   181  func (GlobalTableArgs) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*globalTableArgs)(nil)).Elem()
   183  }
   184  
   185  type GlobalTableInput interface {
   186  	pulumi.Input
   187  
   188  	ToGlobalTableOutput() GlobalTableOutput
   189  	ToGlobalTableOutputWithContext(ctx context.Context) GlobalTableOutput
   190  }
   191  
   192  func (*GlobalTable) ElementType() reflect.Type {
   193  	return reflect.TypeOf((**GlobalTable)(nil)).Elem()
   194  }
   195  
   196  func (i *GlobalTable) ToGlobalTableOutput() GlobalTableOutput {
   197  	return i.ToGlobalTableOutputWithContext(context.Background())
   198  }
   199  
   200  func (i *GlobalTable) ToGlobalTableOutputWithContext(ctx context.Context) GlobalTableOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(GlobalTableOutput)
   202  }
   203  
   204  // GlobalTableArrayInput is an input type that accepts GlobalTableArray and GlobalTableArrayOutput values.
   205  // You can construct a concrete instance of `GlobalTableArrayInput` via:
   206  //
   207  //	GlobalTableArray{ GlobalTableArgs{...} }
   208  type GlobalTableArrayInput interface {
   209  	pulumi.Input
   210  
   211  	ToGlobalTableArrayOutput() GlobalTableArrayOutput
   212  	ToGlobalTableArrayOutputWithContext(context.Context) GlobalTableArrayOutput
   213  }
   214  
   215  type GlobalTableArray []GlobalTableInput
   216  
   217  func (GlobalTableArray) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*[]*GlobalTable)(nil)).Elem()
   219  }
   220  
   221  func (i GlobalTableArray) ToGlobalTableArrayOutput() GlobalTableArrayOutput {
   222  	return i.ToGlobalTableArrayOutputWithContext(context.Background())
   223  }
   224  
   225  func (i GlobalTableArray) ToGlobalTableArrayOutputWithContext(ctx context.Context) GlobalTableArrayOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(GlobalTableArrayOutput)
   227  }
   228  
   229  // GlobalTableMapInput is an input type that accepts GlobalTableMap and GlobalTableMapOutput values.
   230  // You can construct a concrete instance of `GlobalTableMapInput` via:
   231  //
   232  //	GlobalTableMap{ "key": GlobalTableArgs{...} }
   233  type GlobalTableMapInput interface {
   234  	pulumi.Input
   235  
   236  	ToGlobalTableMapOutput() GlobalTableMapOutput
   237  	ToGlobalTableMapOutputWithContext(context.Context) GlobalTableMapOutput
   238  }
   239  
   240  type GlobalTableMap map[string]GlobalTableInput
   241  
   242  func (GlobalTableMap) ElementType() reflect.Type {
   243  	return reflect.TypeOf((*map[string]*GlobalTable)(nil)).Elem()
   244  }
   245  
   246  func (i GlobalTableMap) ToGlobalTableMapOutput() GlobalTableMapOutput {
   247  	return i.ToGlobalTableMapOutputWithContext(context.Background())
   248  }
   249  
   250  func (i GlobalTableMap) ToGlobalTableMapOutputWithContext(ctx context.Context) GlobalTableMapOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(GlobalTableMapOutput)
   252  }
   253  
   254  type GlobalTableOutput struct{ *pulumi.OutputState }
   255  
   256  func (GlobalTableOutput) ElementType() reflect.Type {
   257  	return reflect.TypeOf((**GlobalTable)(nil)).Elem()
   258  }
   259  
   260  func (o GlobalTableOutput) ToGlobalTableOutput() GlobalTableOutput {
   261  	return o
   262  }
   263  
   264  func (o GlobalTableOutput) ToGlobalTableOutputWithContext(ctx context.Context) GlobalTableOutput {
   265  	return o
   266  }
   267  
   268  // The ARN of the DynamoDB Global Table
   269  func (o GlobalTableOutput) Arn() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *GlobalTable) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   271  }
   272  
   273  // The name of the global table. Must match underlying DynamoDB Table names in all regions.
   274  func (o GlobalTableOutput) Name() pulumi.StringOutput {
   275  	return o.ApplyT(func(v *GlobalTable) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   276  }
   277  
   278  // Underlying DynamoDB Table. At least 1 replica must be defined. See below.
   279  func (o GlobalTableOutput) Replicas() GlobalTableReplicaArrayOutput {
   280  	return o.ApplyT(func(v *GlobalTable) GlobalTableReplicaArrayOutput { return v.Replicas }).(GlobalTableReplicaArrayOutput)
   281  }
   282  
   283  type GlobalTableArrayOutput struct{ *pulumi.OutputState }
   284  
   285  func (GlobalTableArrayOutput) ElementType() reflect.Type {
   286  	return reflect.TypeOf((*[]*GlobalTable)(nil)).Elem()
   287  }
   288  
   289  func (o GlobalTableArrayOutput) ToGlobalTableArrayOutput() GlobalTableArrayOutput {
   290  	return o
   291  }
   292  
   293  func (o GlobalTableArrayOutput) ToGlobalTableArrayOutputWithContext(ctx context.Context) GlobalTableArrayOutput {
   294  	return o
   295  }
   296  
   297  func (o GlobalTableArrayOutput) Index(i pulumi.IntInput) GlobalTableOutput {
   298  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *GlobalTable {
   299  		return vs[0].([]*GlobalTable)[vs[1].(int)]
   300  	}).(GlobalTableOutput)
   301  }
   302  
   303  type GlobalTableMapOutput struct{ *pulumi.OutputState }
   304  
   305  func (GlobalTableMapOutput) ElementType() reflect.Type {
   306  	return reflect.TypeOf((*map[string]*GlobalTable)(nil)).Elem()
   307  }
   308  
   309  func (o GlobalTableMapOutput) ToGlobalTableMapOutput() GlobalTableMapOutput {
   310  	return o
   311  }
   312  
   313  func (o GlobalTableMapOutput) ToGlobalTableMapOutputWithContext(ctx context.Context) GlobalTableMapOutput {
   314  	return o
   315  }
   316  
   317  func (o GlobalTableMapOutput) MapIndex(k pulumi.StringInput) GlobalTableOutput {
   318  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *GlobalTable {
   319  		return vs[0].(map[string]*GlobalTable)[vs[1].(string)]
   320  	}).(GlobalTableOutput)
   321  }
   322  
   323  func init() {
   324  	pulumi.RegisterInputType(reflect.TypeOf((*GlobalTableInput)(nil)).Elem(), &GlobalTable{})
   325  	pulumi.RegisterInputType(reflect.TypeOf((*GlobalTableArrayInput)(nil)).Elem(), GlobalTableArray{})
   326  	pulumi.RegisterInputType(reflect.TypeOf((*GlobalTableMapInput)(nil)).Elem(), GlobalTableMap{})
   327  	pulumi.RegisterOutputType(GlobalTableOutput{})
   328  	pulumi.RegisterOutputType(GlobalTableArrayOutput{})
   329  	pulumi.RegisterOutputType(GlobalTableMapOutput{})
   330  }