InterviewHubPRO
Section Overview
Q49

Question 49 of 65

Part 4: Storage, Content Delivery & Databases (36 - 50)

75%
AWS Cloud Architecture•Part 4: Storage, Content Delivery & Databases (36 - 50)

DynamoDB GSI vs LSI.

In Simple Words:

  • LSI (Local Secondary Index): Uses the same Partition Key as the table with a different Sort Key. Max 10GB per partition; must be created when the table is created.
  • GSI (Global Secondary Index): Can choose completely new Partition and Sort keys. No storage limits; scales throughput independently; can be created anytime.
hcl
resource "aws_dynamodb_table" "app_table" {
  name         = "AppTable"
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "PK"
  range_key    = "SK"

  global_secondary_index {
    name            = "GSI1"
    hash_key        = "GSI1PK"
    range_key       = "GSI1SK"
    projection_type = "ALL"
  }
}