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

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

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

aws.dynamodb.getTableItem

Explore with Pulumi AI

aws logo

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

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

    Data source for retrieving a value from an AWS DynamoDB table.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const test = aws.dynamodb.getTableItem({
        tableName: example.name,
        expressionAttributeNames: {
            "#P": "Percentile",
        },
        projectionExpression: "#P",
        key: `{
    	"hashKey": {"S": "example"}
    }
    `,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    test = aws.dynamodb.get_table_item(table_name=example["name"],
        expression_attribute_names={
            "#P": "Percentile",
        },
        projection_expression="#P",
        key="""{
    	"hashKey": {"S": "example"}
    }
    """)
    
    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.LookupTableItem(ctx, &dynamodb.LookupTableItemArgs{
    			TableName: 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
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var test = Aws.DynamoDB.GetTableItem.Invoke(new()
        {
            TableName = example.Name,
            ExpressionAttributeNames = 
            {
                { "#P", "Percentile" },
            },
            ProjectionExpression = "#P",
            Key = @"{
    	""hashKey"": {""S"": ""example""}
    }
    ",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.dynamodb.DynamodbFunctions;
    import com.pulumi.aws.dynamodb.inputs.GetTableItemArgs;
    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) {
            final var test = DynamodbFunctions.getTableItem(GetTableItemArgs.builder()
                .tableName(example.name())
                .expressionAttributeNames(Map.of("#P", "Percentile"))
                .projectionExpression("#P")
                .key("""
    {
    	"hashKey": {"S": "example"}
    }
                """)
                .build());
    
        }
    }
    
    variables:
      test:
        fn::invoke:
          Function: aws:dynamodb:getTableItem
          Arguments:
            tableName: ${example.name}
            expressionAttributeNames:
              '#P': Percentile
            projectionExpression: '#P'
            key: |
              {
              	"hashKey": {"S": "example"}
              }          
    

    Using getTableItem

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getTableItem(args: GetTableItemArgs, opts?: InvokeOptions): Promise<GetTableItemResult>
    function getTableItemOutput(args: GetTableItemOutputArgs, opts?: InvokeOptions): Output<GetTableItemResult>
    def get_table_item(expression_attribute_names: Optional[Mapping[str, str]] = None,
                       key: Optional[str] = None,
                       projection_expression: Optional[str] = None,
                       table_name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetTableItemResult
    def get_table_item_output(expression_attribute_names: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                       key: Optional[pulumi.Input[str]] = None,
                       projection_expression: Optional[pulumi.Input[str]] = None,
                       table_name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetTableItemResult]
    func LookupTableItem(ctx *Context, args *LookupTableItemArgs, opts ...InvokeOption) (*LookupTableItemResult, error)
    func LookupTableItemOutput(ctx *Context, args *LookupTableItemOutputArgs, opts ...InvokeOption) LookupTableItemResultOutput

    > Note: This function is named LookupTableItem in the Go SDK.

    public static class GetTableItem 
    {
        public static Task<GetTableItemResult> InvokeAsync(GetTableItemArgs args, InvokeOptions? opts = null)
        public static Output<GetTableItemResult> Invoke(GetTableItemInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetTableItemResult> getTableItem(GetTableItemArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:dynamodb/getTableItem:getTableItem
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Key string

    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:

    TableName string
    The name of the table containing the requested item.
    ExpressionAttributeNames Dictionary<string, string>
    ProjectionExpression string
    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.
    Key string

    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:

    TableName string
    The name of the table containing the requested item.
    ExpressionAttributeNames map[string]string
    ProjectionExpression string
    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.
    key String

    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:

    tableName String
    The name of the table containing the requested item.
    expressionAttributeNames Map<String,String>
    projectionExpression String
    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.
    key string

    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:

    tableName string
    The name of the table containing the requested item.
    expressionAttributeNames {[key: string]: string}
    projectionExpression string
    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.
    key str

    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:

    table_name str
    The name of the table containing the requested item.
    expression_attribute_names Mapping[str, str]
    projection_expression str
    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.
    key String

    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:

    tableName String
    The name of the table containing the requested item.
    expressionAttributeNames Map<String>
    projectionExpression String
    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.

    getTableItem Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Item string
    JSON representation of a map of attribute names to AttributeValue objects, as specified by ProjectionExpression.
    Key string
    TableName string
    ExpressionAttributeNames Dictionary<string, string>
    ProjectionExpression string
    Id string
    The provider-assigned unique ID for this managed resource.
    Item string
    JSON representation of a map of attribute names to AttributeValue objects, as specified by ProjectionExpression.
    Key string
    TableName string
    ExpressionAttributeNames map[string]string
    ProjectionExpression string
    id String
    The provider-assigned unique ID for this managed resource.
    item String
    JSON representation of a map of attribute names to AttributeValue objects, as specified by ProjectionExpression.
    key String
    tableName String
    expressionAttributeNames Map<String,String>
    projectionExpression String
    id string
    The provider-assigned unique ID for this managed resource.
    item string
    JSON representation of a map of attribute names to AttributeValue objects, as specified by ProjectionExpression.
    key string
    tableName string
    expressionAttributeNames {[key: string]: string}
    projectionExpression string
    id str
    The provider-assigned unique ID for this managed resource.
    item str
    JSON representation of a map of attribute names to AttributeValue objects, as specified by ProjectionExpression.
    key str
    table_name str
    expression_attribute_names Mapping[str, str]
    projection_expression str
    id String
    The provider-assigned unique ID for this managed resource.
    item String
    JSON representation of a map of attribute names to AttributeValue objects, as specified by ProjectionExpression.
    key String
    tableName String
    expressionAttributeNames Map<String>
    projectionExpression String

    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.32.0 published on Friday, Apr 19, 2024 by Pulumi