Class GlobalSecondaryIndex


  • public class GlobalSecondaryIndex
    extends com.pulumi.resources.CustomResource
    > **WARNING:** Do not combine `aws.dynamodb.GlobalSecondaryIndex` resources in conjunction with `globalSecondaryIndex` on `aws.dynamodb.Table`. Doing so may cause conflicts, perpertual differences, and Global Secondary Indexes being overwritten. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.dynamodb.Table;
     import com.pulumi.aws.dynamodb.TableArgs;
     import com.pulumi.aws.dynamodb.inputs.TableAttributeArgs;
     import com.pulumi.aws.dynamodb.GlobalSecondaryIndex;
     import com.pulumi.aws.dynamodb.GlobalSecondaryIndexArgs;
     import com.pulumi.aws.dynamodb.inputs.GlobalSecondaryIndexProjectionArgs;
     import com.pulumi.aws.dynamodb.inputs.GlobalSecondaryIndexProvisionedThroughputArgs;
     import com.pulumi.aws.dynamodb.inputs.GlobalSecondaryIndexKeySchemaArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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) {
             var exampleTable = new Table("exampleTable", TableArgs.builder()
                 .attributes(            
                     TableAttributeArgs.builder()
                         .name("UserId")
                         .type("S")
                         .build(),
                     TableAttributeArgs.builder()
                         .name("GameTitle")
                         .type("S")
                         .build())
                 .name("example")
                 .billingMode("PROVISIONED")
                 .readCapacity(20)
                 .writeCapacity(20)
                 .hashKey("UserId")
                 .rangeKey("GameTitle")
                 .build());
     
             var example = new GlobalSecondaryIndex("example", GlobalSecondaryIndexArgs.builder()
                 .projection(GlobalSecondaryIndexProjectionArgs.builder()
                     .projectionType("INCLUDE")
                     .nonKeyAttributes("UserId")
                     .build())
                 .provisionedThroughput(GlobalSecondaryIndexProvisionedThroughputArgs.builder()
                     .writeCapacityUnits(10)
                     .readCapacityUnits(10)
                     .build())
                 .keySchemas(GlobalSecondaryIndexKeySchemaArgs.builder()
                     .attributeName("GameTitle")
                     .attributeType("S")
                     .keyType("HASH")
                     .build())
                 .tableName(exampleTable.name())
                 .indexName("GameTitleIndex")
                 .build());
     
         }
     }
     
     
    ### Migrating Use the following steps to migrate existing Global Secondary Indexes defined inline in `globalSecondaryIndex` on an `aws.dynamodb.Table`. For each block `globalSecondaryIndex` create a new `aws.dynamodb.GlobalSecondaryIndex` resource with configuration corresponding to the existing block. For example, starting with the following configuration:
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.dynamodb.Table;
     import com.pulumi.aws.dynamodb.TableArgs;
     import com.pulumi.aws.dynamodb.inputs.TableAttributeArgs;
     import com.pulumi.aws.dynamodb.inputs.TableGlobalSecondaryIndexArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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) {
             var example = new Table("example", TableArgs.builder()
                 .attributes(            
                     TableAttributeArgs.builder()
                         .name("example-key")
                         .type("S")
                         .build(),
                     TableAttributeArgs.builder()
                         .name("example-gsi-key-1")
                         .type("S")
                         .build(),
                     TableAttributeArgs.builder()
                         .name("example-gsi-key-2")
                         .type("S")
                         .build())
                 .globalSecondaryIndexes(            
                     TableGlobalSecondaryIndexArgs.builder()
                         .name("example-index-1")
                         .projectionType("ALL")
                         .hashKey("example-gsi-key-1")
                         .readCapacity(1)
                         .writeCapacity(1)
                         .build(),
                     TableGlobalSecondaryIndexArgs.builder()
                         .name("example-index-2")
                         .projectionType("ALL")
                         .hashKey("example-gsi-key-2")
                         .readCapacity(1)
                         .writeCapacity(1)
                         .build())
                 .name("example-table")
                 .hashKey("example-key")
                 .readCapacity(1)
                 .writeCapacity(1)
                 .build());
     
         }
     }
     
     
    Update the configuration to the following. Note that the schema of `aws.dynamodb.GlobalSecondaryIndex` has some differences with `globalSecondaryIndex` on `aws.dynamodb.Table`. If using Terraform versions prior to v1.5.0, remove the `import` blocks and use the `pulumi import` command. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import DynamoDB tables using the `tableName` and `indexName`, separated by a comma. For example: ```sh $ pulumi import aws:dynamodb/globalSecondaryIndex:GlobalSecondaryIndex example 'example-table,example-index' ```
    • Constructor Detail

      • GlobalSecondaryIndex

        public GlobalSecondaryIndex​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • GlobalSecondaryIndex

        public GlobalSecondaryIndex​(java.lang.String name,
                                    GlobalSecondaryIndexArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • GlobalSecondaryIndex

        public GlobalSecondaryIndex​(java.lang.String name,
                                    GlobalSecondaryIndexArgs args,
                                    @Nullable
                                    com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of the GSI.
      • indexName

        public com.pulumi.core.Output<java.lang.String> indexName()
        Returns:
        Name of the index.
      • keySchemas

        public com.pulumi.core.Output<java.util.List<GlobalSecondaryIndexKeySchema>> keySchemas()
        Returns:
        Set of nested attribute definitions. At least 1 element defining a `HASH` is required. All elements with the `keyType` of `HASH` must precede elements with `keyType` of `RANGE`. Changing any values in `keySchema` will re-create the resource. See `keySchema` below.
      • onDemandThroughput

        public com.pulumi.core.Output<java.util.Optional<GlobalSecondaryIndexOnDemandThroughput>> onDemandThroughput()
        Returns:
        Sets the maximum number of read and write units for the index. See `onDemandThroughput` below. Only valid if the table's `billingMode` is `PAY_PER_REQUEST`.
      • projection

        public com.pulumi.core.Output<java.util.Optional<GlobalSecondaryIndexProjection>> projection()
        Returns:
        Describes which attributes from the table are represented in the index. See `projection` below.
      • provisionedThroughput

        public com.pulumi.core.Output<java.util.Optional<GlobalSecondaryIndexProvisionedThroughput>> provisionedThroughput()
        Returns:
        Provisioned throughput for the index. See `provisionedThroughput` below. Required if the table's `billingMode` is `PROVISIONED`.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • tableName

        public com.pulumi.core.Output<java.lang.String> tableName()
        Returns:
        Name of the table this index belongs to. The following arguments are optional:
      • warmThroughput

        public com.pulumi.core.Output<GlobalSecondaryIndexWarmThroughput> warmThroughput()
        Returns:
        Sets the number of warm read and write units for this index. See `warmThroughput` below.
      • get

        public static GlobalSecondaryIndex get​(java.lang.String name,
                                               com.pulumi.core.Output<java.lang.String> id,
                                               @Nullable
                                               GlobalSecondaryIndexState state,
                                               @Nullable
                                               com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.