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

479
Vistas
AWS CDK - Cannot use tokens in construct ID - How do I dynamically name constructs based off the names of other constructs?

I want to create the same CW alarm/metrics for a number of DynamoDB tables in cdk, my instinct was to try to use a for loop to append the name of the DDB table to the CW alarm, but doing so generates the following error: Cannot use tokens in construct ID

It makes sense, because the token has yet to be evaluated so its just a placeholder value. But then what would a good alternative be to sequentially naming the alarms?

My usecase isn't that complicated I could just repeat the same code X times and tweak the name each time, but that seems like an incorrect approach.

I'm using the bellow code for inspiration, but I can't see what values I can call on that wouldn't trigger this error.

https://aws.amazon.com/blogs/developer/aws-cdk-developer-preview/

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

0

You should use the id or uniqueId of the table, something like:

for (const table of tables) {
  new cloudwatch.Alarm(this, `AlarmFor${table.node.id}`, ...); // or table.node.uniqueId
}

But a better pattern could be to create a TableWithAlarm construct and instantiate it multiple times in your stack.

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