github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/dynamodb/getTableItem.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 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Data source for retrieving a value from an AWS DynamoDB table. 15 // 16 // ## Example Usage 17 // 18 // ### Basic Usage 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // _, err := dynamodb.LookupTableItem(ctx, &dynamodb.LookupTableItemArgs{ 34 // TableName: example.Name, 35 // ExpressionAttributeNames: map[string]interface{}{ 36 // "#P": "Percentile", 37 // }, 38 // ProjectionExpression: pulumi.StringRef("#P"), 39 // Key: "{\n \"hashKey\": {\"S\": \"example\"}\n}\n", 40 // }, nil) 41 // if err != nil { 42 // return err 43 // } 44 // return nil 45 // }) 46 // } 47 // 48 // ``` 49 // <!--End PulumiCodeChooser --> 50 func LookupTableItem(ctx *pulumi.Context, args *LookupTableItemArgs, opts ...pulumi.InvokeOption) (*LookupTableItemResult, error) { 51 opts = internal.PkgInvokeDefaultOpts(opts) 52 var rv LookupTableItemResult 53 err := ctx.Invoke("aws:dynamodb/getTableItem:getTableItem", args, &rv, opts...) 54 if err != nil { 55 return nil, err 56 } 57 return &rv, nil 58 } 59 60 // A collection of arguments for invoking getTableItem. 61 type LookupTableItemArgs struct { 62 ExpressionAttributeNames map[string]string `pulumi:"expressionAttributeNames"` 63 // A map of attribute names to AttributeValue objects, representing the primary key of the item to retrieve. 64 // For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key. 65 // 66 // The following arguments are optional: 67 Key string `pulumi:"key"` 68 // A string that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas. 69 // If no attribute names are specified, then all attributes are returned. If any of the requested attributes are not found, they do not appear in the result. 70 ProjectionExpression *string `pulumi:"projectionExpression"` 71 // The name of the table containing the requested item. 72 TableName string `pulumi:"tableName"` 73 } 74 75 // A collection of values returned by getTableItem. 76 type LookupTableItemResult struct { 77 ExpressionAttributeNames map[string]string `pulumi:"expressionAttributeNames"` 78 // The provider-assigned unique ID for this managed resource. 79 Id string `pulumi:"id"` 80 // JSON representation of a map of attribute names to [AttributeValue](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html) objects, as specified by ProjectionExpression. 81 Item string `pulumi:"item"` 82 Key string `pulumi:"key"` 83 ProjectionExpression *string `pulumi:"projectionExpression"` 84 TableName string `pulumi:"tableName"` 85 } 86 87 func LookupTableItemOutput(ctx *pulumi.Context, args LookupTableItemOutputArgs, opts ...pulumi.InvokeOption) LookupTableItemResultOutput { 88 return pulumi.ToOutputWithContext(context.Background(), args). 89 ApplyT(func(v interface{}) (LookupTableItemResult, error) { 90 args := v.(LookupTableItemArgs) 91 r, err := LookupTableItem(ctx, &args, opts...) 92 var s LookupTableItemResult 93 if r != nil { 94 s = *r 95 } 96 return s, err 97 }).(LookupTableItemResultOutput) 98 } 99 100 // A collection of arguments for invoking getTableItem. 101 type LookupTableItemOutputArgs struct { 102 ExpressionAttributeNames pulumi.StringMapInput `pulumi:"expressionAttributeNames"` 103 // A map of attribute names to AttributeValue objects, representing the primary key of the item to retrieve. 104 // For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key. 105 // 106 // The following arguments are optional: 107 Key pulumi.StringInput `pulumi:"key"` 108 // A string that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas. 109 // If no attribute names are specified, then all attributes are returned. If any of the requested attributes are not found, they do not appear in the result. 110 ProjectionExpression pulumi.StringPtrInput `pulumi:"projectionExpression"` 111 // The name of the table containing the requested item. 112 TableName pulumi.StringInput `pulumi:"tableName"` 113 } 114 115 func (LookupTableItemOutputArgs) ElementType() reflect.Type { 116 return reflect.TypeOf((*LookupTableItemArgs)(nil)).Elem() 117 } 118 119 // A collection of values returned by getTableItem. 120 type LookupTableItemResultOutput struct{ *pulumi.OutputState } 121 122 func (LookupTableItemResultOutput) ElementType() reflect.Type { 123 return reflect.TypeOf((*LookupTableItemResult)(nil)).Elem() 124 } 125 126 func (o LookupTableItemResultOutput) ToLookupTableItemResultOutput() LookupTableItemResultOutput { 127 return o 128 } 129 130 func (o LookupTableItemResultOutput) ToLookupTableItemResultOutputWithContext(ctx context.Context) LookupTableItemResultOutput { 131 return o 132 } 133 134 func (o LookupTableItemResultOutput) ExpressionAttributeNames() pulumi.StringMapOutput { 135 return o.ApplyT(func(v LookupTableItemResult) map[string]string { return v.ExpressionAttributeNames }).(pulumi.StringMapOutput) 136 } 137 138 // The provider-assigned unique ID for this managed resource. 139 func (o LookupTableItemResultOutput) Id() pulumi.StringOutput { 140 return o.ApplyT(func(v LookupTableItemResult) string { return v.Id }).(pulumi.StringOutput) 141 } 142 143 // JSON representation of a map of attribute names to [AttributeValue](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html) objects, as specified by ProjectionExpression. 144 func (o LookupTableItemResultOutput) Item() pulumi.StringOutput { 145 return o.ApplyT(func(v LookupTableItemResult) string { return v.Item }).(pulumi.StringOutput) 146 } 147 148 func (o LookupTableItemResultOutput) Key() pulumi.StringOutput { 149 return o.ApplyT(func(v LookupTableItemResult) string { return v.Key }).(pulumi.StringOutput) 150 } 151 152 func (o LookupTableItemResultOutput) ProjectionExpression() pulumi.StringPtrOutput { 153 return o.ApplyT(func(v LookupTableItemResult) *string { return v.ProjectionExpression }).(pulumi.StringPtrOutput) 154 } 155 156 func (o LookupTableItemResultOutput) TableName() pulumi.StringOutput { 157 return o.ApplyT(func(v LookupTableItemResult) string { return v.TableName }).(pulumi.StringOutput) 158 } 159 160 func init() { 161 pulumi.RegisterOutputType(LookupTableItemResultOutput{}) 162 }