github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/timestreamwrite/table.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 timestreamwrite
     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  // Provides a Timestream table resource.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/timestreamwrite"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := timestreamwrite.NewTable(ctx, "example", &timestreamwrite.TableArgs{
    35  //				DatabaseName: pulumi.Any(exampleAwsTimestreamwriteDatabase.DatabaseName),
    36  //				TableName:    pulumi.String("example"),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			return nil
    42  //		})
    43  //	}
    44  //
    45  // ```
    46  // <!--End PulumiCodeChooser -->
    47  //
    48  // ### Full usage
    49  //
    50  // <!--Start PulumiCodeChooser -->
    51  // ```go
    52  // package main
    53  //
    54  // import (
    55  //
    56  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/timestreamwrite"
    57  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    58  //
    59  // )
    60  //
    61  //	func main() {
    62  //		pulumi.Run(func(ctx *pulumi.Context) error {
    63  //			_, err := timestreamwrite.NewTable(ctx, "example", &timestreamwrite.TableArgs{
    64  //				DatabaseName: pulumi.Any(exampleAwsTimestreamwriteDatabase.DatabaseName),
    65  //				TableName:    pulumi.String("example"),
    66  //				RetentionProperties: &timestreamwrite.TableRetentionPropertiesArgs{
    67  //					MagneticStoreRetentionPeriodInDays: pulumi.Int(30),
    68  //					MemoryStoreRetentionPeriodInHours:  pulumi.Int(8),
    69  //				},
    70  //				Tags: pulumi.StringMap{
    71  //					"Name": pulumi.String("example-timestream-table"),
    72  //				},
    73  //			})
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			return nil
    78  //		})
    79  //	}
    80  //
    81  // ```
    82  // <!--End PulumiCodeChooser -->
    83  //
    84  // ### Customer-defined Partition Key
    85  //
    86  // <!--Start PulumiCodeChooser -->
    87  // ```go
    88  // package main
    89  //
    90  // import (
    91  //
    92  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/timestreamwrite"
    93  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    94  //
    95  // )
    96  //
    97  //	func main() {
    98  //		pulumi.Run(func(ctx *pulumi.Context) error {
    99  //			_, err := timestreamwrite.NewTable(ctx, "example", &timestreamwrite.TableArgs{
   100  //				DatabaseName: pulumi.Any(exampleAwsTimestreamwriteDatabase.DatabaseName),
   101  //				TableName:    pulumi.String("example"),
   102  //				Schema: &timestreamwrite.TableSchemaArgs{
   103  //					CompositePartitionKey: &timestreamwrite.TableSchemaCompositePartitionKeyArgs{
   104  //						EnforcementInRecord: pulumi.String("REQUIRED"),
   105  //						Name:                pulumi.String("attr1"),
   106  //						Type:                pulumi.String("DIMENSION"),
   107  //					},
   108  //				},
   109  //			})
   110  //			if err != nil {
   111  //				return err
   112  //			}
   113  //			return nil
   114  //		})
   115  //	}
   116  //
   117  // ```
   118  // <!--End PulumiCodeChooser -->
   119  //
   120  // ## Import
   121  //
   122  // Using `pulumi import`, import Timestream tables using the `table_name` and `database_name` separate by a colon (`:`). For example:
   123  //
   124  // ```sh
   125  // $ pulumi import aws:timestreamwrite/table:Table example ExampleTable:ExampleDatabase
   126  // ```
   127  type Table struct {
   128  	pulumi.CustomResourceState
   129  
   130  	// The ARN that uniquely identifies this table.
   131  	Arn pulumi.StringOutput `pulumi:"arn"`
   132  	// The name of the Timestream database.
   133  	DatabaseName pulumi.StringOutput `pulumi:"databaseName"`
   134  	// Contains properties to set on the table when enabling magnetic store writes. See Magnetic Store Write Properties below for more details.
   135  	MagneticStoreWriteProperties TableMagneticStoreWritePropertiesOutput `pulumi:"magneticStoreWriteProperties"`
   136  	// The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided, `magneticStoreRetentionPeriodInDays` default to 73000 and `memoryStoreRetentionPeriodInHours` defaults to 6.
   137  	RetentionProperties TableRetentionPropertiesOutput `pulumi:"retentionProperties"`
   138  	// The schema of the table. See Schema below for more details.
   139  	Schema TableSchemaOutput `pulumi:"schema"`
   140  	// The name of the Timestream table.
   141  	TableName pulumi.StringOutput `pulumi:"tableName"`
   142  	// Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   143  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   144  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   145  	//
   146  	// Deprecated: Please use `tags` instead.
   147  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   148  }
   149  
   150  // NewTable registers a new resource with the given unique name, arguments, and options.
   151  func NewTable(ctx *pulumi.Context,
   152  	name string, args *TableArgs, opts ...pulumi.ResourceOption) (*Table, error) {
   153  	if args == nil {
   154  		return nil, errors.New("missing one or more required arguments")
   155  	}
   156  
   157  	if args.DatabaseName == nil {
   158  		return nil, errors.New("invalid value for required argument 'DatabaseName'")
   159  	}
   160  	if args.TableName == nil {
   161  		return nil, errors.New("invalid value for required argument 'TableName'")
   162  	}
   163  	opts = internal.PkgResourceDefaultOpts(opts)
   164  	var resource Table
   165  	err := ctx.RegisterResource("aws:timestreamwrite/table:Table", name, args, &resource, opts...)
   166  	if err != nil {
   167  		return nil, err
   168  	}
   169  	return &resource, nil
   170  }
   171  
   172  // GetTable gets an existing Table resource's state with the given name, ID, and optional
   173  // state properties that are used to uniquely qualify the lookup (nil if not required).
   174  func GetTable(ctx *pulumi.Context,
   175  	name string, id pulumi.IDInput, state *TableState, opts ...pulumi.ResourceOption) (*Table, error) {
   176  	var resource Table
   177  	err := ctx.ReadResource("aws:timestreamwrite/table:Table", name, id, state, &resource, opts...)
   178  	if err != nil {
   179  		return nil, err
   180  	}
   181  	return &resource, nil
   182  }
   183  
   184  // Input properties used for looking up and filtering Table resources.
   185  type tableState struct {
   186  	// The ARN that uniquely identifies this table.
   187  	Arn *string `pulumi:"arn"`
   188  	// The name of the Timestream database.
   189  	DatabaseName *string `pulumi:"databaseName"`
   190  	// Contains properties to set on the table when enabling magnetic store writes. See Magnetic Store Write Properties below for more details.
   191  	MagneticStoreWriteProperties *TableMagneticStoreWriteProperties `pulumi:"magneticStoreWriteProperties"`
   192  	// The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided, `magneticStoreRetentionPeriodInDays` default to 73000 and `memoryStoreRetentionPeriodInHours` defaults to 6.
   193  	RetentionProperties *TableRetentionProperties `pulumi:"retentionProperties"`
   194  	// The schema of the table. See Schema below for more details.
   195  	Schema *TableSchema `pulumi:"schema"`
   196  	// The name of the Timestream table.
   197  	TableName *string `pulumi:"tableName"`
   198  	// Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   199  	Tags map[string]string `pulumi:"tags"`
   200  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   201  	//
   202  	// Deprecated: Please use `tags` instead.
   203  	TagsAll map[string]string `pulumi:"tagsAll"`
   204  }
   205  
   206  type TableState struct {
   207  	// The ARN that uniquely identifies this table.
   208  	Arn pulumi.StringPtrInput
   209  	// The name of the Timestream database.
   210  	DatabaseName pulumi.StringPtrInput
   211  	// Contains properties to set on the table when enabling magnetic store writes. See Magnetic Store Write Properties below for more details.
   212  	MagneticStoreWriteProperties TableMagneticStoreWritePropertiesPtrInput
   213  	// The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided, `magneticStoreRetentionPeriodInDays` default to 73000 and `memoryStoreRetentionPeriodInHours` defaults to 6.
   214  	RetentionProperties TableRetentionPropertiesPtrInput
   215  	// The schema of the table. See Schema below for more details.
   216  	Schema TableSchemaPtrInput
   217  	// The name of the Timestream table.
   218  	TableName pulumi.StringPtrInput
   219  	// Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   220  	Tags pulumi.StringMapInput
   221  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   222  	//
   223  	// Deprecated: Please use `tags` instead.
   224  	TagsAll pulumi.StringMapInput
   225  }
   226  
   227  func (TableState) ElementType() reflect.Type {
   228  	return reflect.TypeOf((*tableState)(nil)).Elem()
   229  }
   230  
   231  type tableArgs struct {
   232  	// The name of the Timestream database.
   233  	DatabaseName string `pulumi:"databaseName"`
   234  	// Contains properties to set on the table when enabling magnetic store writes. See Magnetic Store Write Properties below for more details.
   235  	MagneticStoreWriteProperties *TableMagneticStoreWriteProperties `pulumi:"magneticStoreWriteProperties"`
   236  	// The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided, `magneticStoreRetentionPeriodInDays` default to 73000 and `memoryStoreRetentionPeriodInHours` defaults to 6.
   237  	RetentionProperties *TableRetentionProperties `pulumi:"retentionProperties"`
   238  	// The schema of the table. See Schema below for more details.
   239  	Schema *TableSchema `pulumi:"schema"`
   240  	// The name of the Timestream table.
   241  	TableName string `pulumi:"tableName"`
   242  	// Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   243  	Tags map[string]string `pulumi:"tags"`
   244  }
   245  
   246  // The set of arguments for constructing a Table resource.
   247  type TableArgs struct {
   248  	// The name of the Timestream database.
   249  	DatabaseName pulumi.StringInput
   250  	// Contains properties to set on the table when enabling magnetic store writes. See Magnetic Store Write Properties below for more details.
   251  	MagneticStoreWriteProperties TableMagneticStoreWritePropertiesPtrInput
   252  	// The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided, `magneticStoreRetentionPeriodInDays` default to 73000 and `memoryStoreRetentionPeriodInHours` defaults to 6.
   253  	RetentionProperties TableRetentionPropertiesPtrInput
   254  	// The schema of the table. See Schema below for more details.
   255  	Schema TableSchemaPtrInput
   256  	// The name of the Timestream table.
   257  	TableName pulumi.StringInput
   258  	// Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   259  	Tags pulumi.StringMapInput
   260  }
   261  
   262  func (TableArgs) ElementType() reflect.Type {
   263  	return reflect.TypeOf((*tableArgs)(nil)).Elem()
   264  }
   265  
   266  type TableInput interface {
   267  	pulumi.Input
   268  
   269  	ToTableOutput() TableOutput
   270  	ToTableOutputWithContext(ctx context.Context) TableOutput
   271  }
   272  
   273  func (*Table) ElementType() reflect.Type {
   274  	return reflect.TypeOf((**Table)(nil)).Elem()
   275  }
   276  
   277  func (i *Table) ToTableOutput() TableOutput {
   278  	return i.ToTableOutputWithContext(context.Background())
   279  }
   280  
   281  func (i *Table) ToTableOutputWithContext(ctx context.Context) TableOutput {
   282  	return pulumi.ToOutputWithContext(ctx, i).(TableOutput)
   283  }
   284  
   285  // TableArrayInput is an input type that accepts TableArray and TableArrayOutput values.
   286  // You can construct a concrete instance of `TableArrayInput` via:
   287  //
   288  //	TableArray{ TableArgs{...} }
   289  type TableArrayInput interface {
   290  	pulumi.Input
   291  
   292  	ToTableArrayOutput() TableArrayOutput
   293  	ToTableArrayOutputWithContext(context.Context) TableArrayOutput
   294  }
   295  
   296  type TableArray []TableInput
   297  
   298  func (TableArray) ElementType() reflect.Type {
   299  	return reflect.TypeOf((*[]*Table)(nil)).Elem()
   300  }
   301  
   302  func (i TableArray) ToTableArrayOutput() TableArrayOutput {
   303  	return i.ToTableArrayOutputWithContext(context.Background())
   304  }
   305  
   306  func (i TableArray) ToTableArrayOutputWithContext(ctx context.Context) TableArrayOutput {
   307  	return pulumi.ToOutputWithContext(ctx, i).(TableArrayOutput)
   308  }
   309  
   310  // TableMapInput is an input type that accepts TableMap and TableMapOutput values.
   311  // You can construct a concrete instance of `TableMapInput` via:
   312  //
   313  //	TableMap{ "key": TableArgs{...} }
   314  type TableMapInput interface {
   315  	pulumi.Input
   316  
   317  	ToTableMapOutput() TableMapOutput
   318  	ToTableMapOutputWithContext(context.Context) TableMapOutput
   319  }
   320  
   321  type TableMap map[string]TableInput
   322  
   323  func (TableMap) ElementType() reflect.Type {
   324  	return reflect.TypeOf((*map[string]*Table)(nil)).Elem()
   325  }
   326  
   327  func (i TableMap) ToTableMapOutput() TableMapOutput {
   328  	return i.ToTableMapOutputWithContext(context.Background())
   329  }
   330  
   331  func (i TableMap) ToTableMapOutputWithContext(ctx context.Context) TableMapOutput {
   332  	return pulumi.ToOutputWithContext(ctx, i).(TableMapOutput)
   333  }
   334  
   335  type TableOutput struct{ *pulumi.OutputState }
   336  
   337  func (TableOutput) ElementType() reflect.Type {
   338  	return reflect.TypeOf((**Table)(nil)).Elem()
   339  }
   340  
   341  func (o TableOutput) ToTableOutput() TableOutput {
   342  	return o
   343  }
   344  
   345  func (o TableOutput) ToTableOutputWithContext(ctx context.Context) TableOutput {
   346  	return o
   347  }
   348  
   349  // The ARN that uniquely identifies this table.
   350  func (o TableOutput) Arn() pulumi.StringOutput {
   351  	return o.ApplyT(func(v *Table) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   352  }
   353  
   354  // The name of the Timestream database.
   355  func (o TableOutput) DatabaseName() pulumi.StringOutput {
   356  	return o.ApplyT(func(v *Table) pulumi.StringOutput { return v.DatabaseName }).(pulumi.StringOutput)
   357  }
   358  
   359  // Contains properties to set on the table when enabling magnetic store writes. See Magnetic Store Write Properties below for more details.
   360  func (o TableOutput) MagneticStoreWriteProperties() TableMagneticStoreWritePropertiesOutput {
   361  	return o.ApplyT(func(v *Table) TableMagneticStoreWritePropertiesOutput { return v.MagneticStoreWriteProperties }).(TableMagneticStoreWritePropertiesOutput)
   362  }
   363  
   364  // The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided, `magneticStoreRetentionPeriodInDays` default to 73000 and `memoryStoreRetentionPeriodInHours` defaults to 6.
   365  func (o TableOutput) RetentionProperties() TableRetentionPropertiesOutput {
   366  	return o.ApplyT(func(v *Table) TableRetentionPropertiesOutput { return v.RetentionProperties }).(TableRetentionPropertiesOutput)
   367  }
   368  
   369  // The schema of the table. See Schema below for more details.
   370  func (o TableOutput) Schema() TableSchemaOutput {
   371  	return o.ApplyT(func(v *Table) TableSchemaOutput { return v.Schema }).(TableSchemaOutput)
   372  }
   373  
   374  // The name of the Timestream table.
   375  func (o TableOutput) TableName() pulumi.StringOutput {
   376  	return o.ApplyT(func(v *Table) pulumi.StringOutput { return v.TableName }).(pulumi.StringOutput)
   377  }
   378  
   379  // Map of tags to assign to this resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   380  func (o TableOutput) Tags() pulumi.StringMapOutput {
   381  	return o.ApplyT(func(v *Table) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   382  }
   383  
   384  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   385  //
   386  // Deprecated: Please use `tags` instead.
   387  func (o TableOutput) TagsAll() pulumi.StringMapOutput {
   388  	return o.ApplyT(func(v *Table) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   389  }
   390  
   391  type TableArrayOutput struct{ *pulumi.OutputState }
   392  
   393  func (TableArrayOutput) ElementType() reflect.Type {
   394  	return reflect.TypeOf((*[]*Table)(nil)).Elem()
   395  }
   396  
   397  func (o TableArrayOutput) ToTableArrayOutput() TableArrayOutput {
   398  	return o
   399  }
   400  
   401  func (o TableArrayOutput) ToTableArrayOutputWithContext(ctx context.Context) TableArrayOutput {
   402  	return o
   403  }
   404  
   405  func (o TableArrayOutput) Index(i pulumi.IntInput) TableOutput {
   406  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Table {
   407  		return vs[0].([]*Table)[vs[1].(int)]
   408  	}).(TableOutput)
   409  }
   410  
   411  type TableMapOutput struct{ *pulumi.OutputState }
   412  
   413  func (TableMapOutput) ElementType() reflect.Type {
   414  	return reflect.TypeOf((*map[string]*Table)(nil)).Elem()
   415  }
   416  
   417  func (o TableMapOutput) ToTableMapOutput() TableMapOutput {
   418  	return o
   419  }
   420  
   421  func (o TableMapOutput) ToTableMapOutputWithContext(ctx context.Context) TableMapOutput {
   422  	return o
   423  }
   424  
   425  func (o TableMapOutput) MapIndex(k pulumi.StringInput) TableOutput {
   426  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Table {
   427  		return vs[0].(map[string]*Table)[vs[1].(string)]
   428  	}).(TableOutput)
   429  }
   430  
   431  func init() {
   432  	pulumi.RegisterInputType(reflect.TypeOf((*TableInput)(nil)).Elem(), &Table{})
   433  	pulumi.RegisterInputType(reflect.TypeOf((*TableArrayInput)(nil)).Elem(), TableArray{})
   434  	pulumi.RegisterInputType(reflect.TypeOf((*TableMapInput)(nil)).Elem(), TableMap{})
   435  	pulumi.RegisterOutputType(TableOutput{})
   436  	pulumi.RegisterOutputType(TableArrayOutput{})
   437  	pulumi.RegisterOutputType(TableMapOutput{})
   438  }