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 ?

asked a year ago352 views
3 Answers
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
EXPERT
Peter_G
answered a year ago
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.

answered a year ago
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.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions