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 ?

已提问 1 年前374 查看次数
3 回答
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
专家
Peter_G
已回答 1 年前
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.

已回答 1 年前
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.

已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则