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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ