/
getTableItem.go
157 lines (137 loc) · 6.71 KB
/
getTableItem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package dynamodb
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Data source for retrieving a value from an AWS DynamoDB table.
//
// ## Example Usage
// ### Basic Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/dynamodb"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := dynamodb.LookupTableItem(ctx, &dynamodb.LookupTableItemArgs{
// TableName: aws_dynamodb_table.Example.Name,
// ExpressionAttributeNames: map[string]interface{}{
// "#P": "Percentile",
// },
// ProjectionExpression: pulumi.StringRef("#P"),
// Key: "{\n \"hashKey\": {\"S\": \"example\"}\n}\n",
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
func LookupTableItem(ctx *pulumi.Context, args *LookupTableItemArgs, opts ...pulumi.InvokeOption) (*LookupTableItemResult, error) {
var rv LookupTableItemResult
err := ctx.Invoke("aws:dynamodb/getTableItem:getTableItem", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getTableItem.
type LookupTableItemArgs struct {
ExpressionAttributeNames map[string]string `pulumi:"expressionAttributeNames"`
// A map of attribute names to AttributeValue objects, representing the primary key of the item to retrieve.
// 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.
//
// The following arguments are optional:
Key string `pulumi:"key"`
// 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.
// 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.
ProjectionExpression *string `pulumi:"projectionExpression"`
// The name of the table containing the requested item.
TableName string `pulumi:"tableName"`
}
// A collection of values returned by getTableItem.
type LookupTableItemResult struct {
ExpressionAttributeNames map[string]string `pulumi:"expressionAttributeNames"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// 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.
Item string `pulumi:"item"`
Key string `pulumi:"key"`
ProjectionExpression *string `pulumi:"projectionExpression"`
TableName string `pulumi:"tableName"`
}
func LookupTableItemOutput(ctx *pulumi.Context, args LookupTableItemOutputArgs, opts ...pulumi.InvokeOption) LookupTableItemResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupTableItemResult, error) {
args := v.(LookupTableItemArgs)
r, err := LookupTableItem(ctx, &args, opts...)
var s LookupTableItemResult
if r != nil {
s = *r
}
return s, err
}).(LookupTableItemResultOutput)
}
// A collection of arguments for invoking getTableItem.
type LookupTableItemOutputArgs struct {
ExpressionAttributeNames pulumi.StringMapInput `pulumi:"expressionAttributeNames"`
// A map of attribute names to AttributeValue objects, representing the primary key of the item to retrieve.
// 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.
//
// The following arguments are optional:
Key pulumi.StringInput `pulumi:"key"`
// 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.
// 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.
ProjectionExpression pulumi.StringPtrInput `pulumi:"projectionExpression"`
// The name of the table containing the requested item.
TableName pulumi.StringInput `pulumi:"tableName"`
}
func (LookupTableItemOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupTableItemArgs)(nil)).Elem()
}
// A collection of values returned by getTableItem.
type LookupTableItemResultOutput struct{ *pulumi.OutputState }
func (LookupTableItemResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupTableItemResult)(nil)).Elem()
}
func (o LookupTableItemResultOutput) ToLookupTableItemResultOutput() LookupTableItemResultOutput {
return o
}
func (o LookupTableItemResultOutput) ToLookupTableItemResultOutputWithContext(ctx context.Context) LookupTableItemResultOutput {
return o
}
func (o LookupTableItemResultOutput) ExpressionAttributeNames() pulumi.StringMapOutput {
return o.ApplyT(func(v LookupTableItemResult) map[string]string { return v.ExpressionAttributeNames }).(pulumi.StringMapOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o LookupTableItemResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupTableItemResult) string { return v.Id }).(pulumi.StringOutput)
}
// 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.
func (o LookupTableItemResultOutput) Item() pulumi.StringOutput {
return o.ApplyT(func(v LookupTableItemResult) string { return v.Item }).(pulumi.StringOutput)
}
func (o LookupTableItemResultOutput) Key() pulumi.StringOutput {
return o.ApplyT(func(v LookupTableItemResult) string { return v.Key }).(pulumi.StringOutput)
}
func (o LookupTableItemResultOutput) ProjectionExpression() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupTableItemResult) *string { return v.ProjectionExpression }).(pulumi.StringPtrOutput)
}
func (o LookupTableItemResultOutput) TableName() pulumi.StringOutput {
return o.ApplyT(func(v LookupTableItemResult) string { return v.TableName }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(LookupTableItemResultOutput{})
}