How to simultaneously deploy Timestream Database, Table and Scheduled Query

0

We are trying to simultaneously deploy fresh Timestream Database, Table and Scheduled Query with Serverless Framework.

The deployment failed. Cloudformation or Timestream try to validate the SQL query. This validation fails, at this step the database is empty.

CREATE_FAILED: StockProjectionTimestreamScheduleQuery (AWS::Timestream::ScheduledQuery) Resource handler returned message: "line 4:13: Column 'organization_id' does not exist (Service: AmazonTimestreamQuery; Status Code: 400; Error Code: ValidationException; Request ID: TZOGF7H6GCGONFOILEW45UEXI4; Proxy: null)

Does anyone have a solution to handle this kind of deployment ?

preguntada hace un año374 visualizaciones
3 Respuestas
0

In cloudformation you can enforce order by a few ways:

Reference (!Ref) or get an attribute (!GetAtt) from another resource. The resource using the reference or attribute will wait until the resources is finished

Set the DependsOn parameter to force a resource to wait on another resource. This will be what you need here - you need to set the query resource to depend on the table resource

More complex scenarios where db schema's are not deployed by cloudformation Use a WaitHandle with a WaitCondition. You would give the function (assuming it is a function) deploying your database table the waithandle (which is a presigned cloudformation URL). At the end of deploying the table call the wait handle. The function (assuming it is a function) making the query needs to dependon the waithandle. This will ensure the query doesn't happen until the table is created

AWS
EXPERTO
Peter_G
respondido hace un año
0

Thanks for your answer Peter.

I already set up the dependsOn properties for my resources.

The Timestream Table are not described by a static schema. The schema is built on the fly by ingesting events. So I will try the WaitHandle trick and inject some fake events to Timestream.

respondido hace un año
0

I finally managed to deploy the scheduled query with its source table with a custom resource based on a function triggered between the deployments of the table dans the query. This function inject a fake event to the table that force timestream to discover the table schema.

respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas