google/resource-snippets/bigquery-v2/bigquery.jinja (38 lines of code) (raw):
# Copyright 2018 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#% description: Creates a BigQuery dataset and table within the dataset.
#% parameters:
# Can't use deployment name as it is going to be filled in with a generated
# name which has dashes in it, which are not valid bigquery name characters.
{% set DATASET = (env["deployment"] + "dataset")|replace("-","_") %}
{% set TABLE = (env["deployment"] + "table")|replace("-","_") %}
resources:
- name: {{ DATASET }}-test
# type: bigquery.v2.dataset
type: gcp-types/bigquery-v2:datasets
properties:
datasetReference:
datasetId: {{ DATASET }}
- name: {{ TABLE }}-test
# type: bigquery.v2.table
type: gcp-types/bigquery-v2:tables
properties:
datasetId: $(ref.{{ DATASET }}-test.datasetReference.datasetId)
tableReference:
tableId: {{ TABLE }}
# tableMetadataView property allows consumers to set the query parameter
# used on GET requests
{% if properties and properties["tableMetadataView"] %}
tableMetadataView: {{ properties["tableMetadataView"] }}
{% endif %}