Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

92
Vistas
AWS Amplify create Global Secondary Index after DynamoDB table creation

I have a large schema with ~70 tables and many of them connected to each other(194 @connection directives) like this:

type table1 @model {
  id:ID!
  name: String!
  ...
  table2: table2 @connection
}

type table2 @model {
  id:ID!
  ....
}

This works fine. Now my data amount is steadily growing and I need to be able to query for results and sort them.

I've read several articles and found one giving me the advice to create a @key directive to generate a GSI with 2 fields so I can say "Filter the results according to my filter property, sort them by the field "name" and return the first 10 entries, the rest accessible via nextToken parameter"

So I tried to add a GSI like this:

type table1 @model 
@key(name: "byName", fields:["id","name"], queryField:"idByName"){
  id:ID!
  name: String!
  ...
  table2: table2 @connection
}

running

amplify push --minify

I receive the error

Attempting to add a local secondary index to the table1Table table in the table1 stack. Local secondary indexes must be created when the table is created.
An error occured during the push operation: Attempting to add a local secondary index to the table1Table table in the table1 stack.
Local secondary indexes must be created when the table is created.

Why does it create a LSI instead of a GSI? Are there any ways to add @key directives to the tables after they have been created and filled? There are so many datasets from different tables linked with each other so just setting up a new schema would take ages.

Billingmode is PAY_PER_REQUEST if this has some impact.

Any ideas how to proceed?

Thanks in advance!

Regards Christian

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you are using new environment, delete folder #current-cloud-backend first.

Then amplify init created the folder again but alas, with only one file in it amplify-meta.json.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda