1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cloud Deployment Managerを使ってBigQueryのデータセット及びテーブルを作る

Last updated at Posted at 2019-09-11

簡単なデータ可視化ツールのサンプルを作るため、BigQueryにデータセットとテーブルをサクッと作る際にCloud Deployment Managerを利用しました。

小さなyamlなのですが、APIのドキュメントを読んで対応する設定を書くのに少し手間がかかってしまったので置いておきます。

# それぞれ [PROJECT_ID] を置き換えてください
resources:
  - name: test-bq-dataset
    type: bigquery.v2.dataset
    properties:
      datasetReference:
        datasetId: test_bq_dataset
        projectId: [PROJECT_ID]
  - name: test-bq-table
    type: bigquery.v2.table
    properties:
      datasetId: test_bq_dataset
      tableReference:
        datasetId: test_bq_dataset
        projectId: [PROJECT_ID]
        tableId: test_bq_table
      schema:
        fields:
          - name: timestamp
            type: TIMESTAMP
            mode: REQUIRED
          - name: col1
            type: STRING
            mode: REQUIRED
          - name: col2
            type: STRING
            mode: REQUIRED
    metadata:
      dependsOn:
        - test-bq-dataset

ちなみにGCPの公式リポジトリにサンプルはあるのですが、yamlの中でPythonを呼び出していて、挙動を追うのが少し大変だったので自分で書いてしまいました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?