diff --git a/datasets/google_cloud_release_notes/_terraform/google_cloud_release_notes_dataset.tf b/datasets/google_cloud_release_notes/_terraform/google_cloud_release_notes_dataset.tf new file mode 100644 index 000000000..59a3c69a8 --- /dev/null +++ b/datasets/google_cloud_release_notes/_terraform/google_cloud_release_notes_dataset.tf @@ -0,0 +1,26 @@ +/** + * Copyright 2021 Google LLC + * + * 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. + */ + + +resource "google_bigquery_dataset" "google_cloud_release_notes" { + dataset_id = "google_cloud_release_notes" + project = var.project_id + description = "This dataset contains release notes for the majority of generally available Google Cloud products found on cloud.google.com. You can use this BigQuery public dataset to consume release notes programmatically across all products. HTML versions of release notes are available within each product\u0027s documentation and also in a filterable format at https://console.cloud.google.com/release-notes." +} + +output "bigquery_dataset-google_cloud_release_notes-dataset_id" { + value = google_bigquery_dataset.google_cloud_release_notes.dataset_id +} diff --git a/datasets/google_cloud_release_notes/_terraform/provider.tf b/datasets/google_cloud_release_notes/_terraform/provider.tf new file mode 100644 index 000000000..23ab87dcd --- /dev/null +++ b/datasets/google_cloud_release_notes/_terraform/provider.tf @@ -0,0 +1,28 @@ +/** + * Copyright 2021 Google LLC + * + * 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. + */ + + +provider "google" { + project = var.project_id + impersonate_service_account = var.impersonating_acct + region = var.region +} + +data "google_client_openid_userinfo" "me" {} + +output "impersonating-account" { + value = data.google_client_openid_userinfo.me.email +} diff --git a/datasets/google_cloud_release_notes/_terraform/release_notes_pipeline.tf b/datasets/google_cloud_release_notes/_terraform/release_notes_pipeline.tf new file mode 100644 index 000000000..74a42c186 --- /dev/null +++ b/datasets/google_cloud_release_notes/_terraform/release_notes_pipeline.tf @@ -0,0 +1,39 @@ +/** + * Copyright 2021 Google LLC + * + * 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. + */ + + +resource "google_bigquery_table" "release_notes" { + project = var.project_id + dataset_id = "google_cloud_release_notes" + table_id = "release_notes" + + description = "This table contains release notes for the majority of generally available Google Cloud products found on cloud.google.com. You can use this BigQuery public dataset to consume release notes programmatically across all products. HTML versions of release notes are available within each product\u0027s documentation and also in a filterable format at https://console.cloud.google.com/release-notes." + + + + + depends_on = [ + google_bigquery_dataset.google_cloud_release_notes + ] +} + +output "bigquery_table-release_notes-table_id" { + value = google_bigquery_table.release_notes.table_id +} + +output "bigquery_table-release_notes-id" { + value = google_bigquery_table.release_notes.id +} diff --git a/datasets/google_cloud_release_notes/_terraform/variables.tf b/datasets/google_cloud_release_notes/_terraform/variables.tf new file mode 100644 index 000000000..c3ec7c506 --- /dev/null +++ b/datasets/google_cloud_release_notes/_terraform/variables.tf @@ -0,0 +1,23 @@ +/** + * Copyright 2021 Google LLC + * + * 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. + */ + + +variable "project_id" {} +variable "bucket_name_prefix" {} +variable "impersonating_acct" {} +variable "region" {} +variable "env" {} + diff --git a/datasets/google_cloud_release_notes/dataset.yaml b/datasets/google_cloud_release_notes/dataset.yaml new file mode 100644 index 000000000..7a20e6c14 --- /dev/null +++ b/datasets/google_cloud_release_notes/dataset.yaml @@ -0,0 +1,25 @@ +# Copyright 2021 Google LLC +# +# 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. + +dataset: + name: google_cloud_release_notes + friendly_name: ~ + description: ~ + dataset_sources: ~ + terms_of_use: ~ + +resources: + - type: bigquery_dataset + dataset_id: google_cloud_release_notes + description: "This dataset contains release notes for the majority of generally available Google Cloud products found on cloud.google.com. You can use this BigQuery public dataset to consume release notes programmatically across all products. HTML versions of release notes are available within each product's documentation and also in a filterable format at https://console.cloud.google.com/release-notes." diff --git a/datasets/google_cloud_release_notes/release_notes/pipeline.yaml b/datasets/google_cloud_release_notes/release_notes/pipeline.yaml new file mode 100644 index 000000000..2ec9bfbb6 --- /dev/null +++ b/datasets/google_cloud_release_notes/release_notes/pipeline.yaml @@ -0,0 +1,47 @@ +# Copyright 2021 Google LLC +# +# 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. + +--- +resources: + - type: bigquery_table + table_id: release_notes + description: "This table contains release notes for the majority of generally available Google Cloud products found on cloud.google.com. You can use this BigQuery public dataset to consume release notes programmatically across all products. HTML versions of release notes are available within each product's documentation and also in a filterable format at https://console.cloud.google.com/release-notes." + +dag: + airflow_version: 1 + initialize: + dag_id: release_notes + default_args: + owner: "Google" + depends_on_past: False + start_date: '2021-08-05' + max_active_runs: 1 + schedule_interval: "0 5 * * *" # run daily at 5am + catchup: False + default_view: graph + + tasks: + - operator: "BigQueryToBigQueryOperator" + description: "Task to run a BQ to BQ operator" + + args: + task_id: "google_cloud_release_notes" + source_project_dataset_tables: ["{{ var.json.google_cloud_release_notes.release_notes.source_project_dataset_table }}"] + destination_project_dataset_table: "{{ var.json.google_cloud_release_notes.release_notes.destination_project_dataset_table }}" + impersonation_chain: "{{ var.json.google_cloud_release_notes.service_account }}" + write_disposition: "WRITE_TRUNCATE" + gcp_conn_id: "google_cloud_release_notes_conn" + + graph_paths: + - "google_cloud_release_notes" diff --git a/datasets/google_cloud_release_notes/release_notes/release_notes_dag.py b/datasets/google_cloud_release_notes/release_notes/release_notes_dag.py new file mode 100644 index 000000000..853bd01ab --- /dev/null +++ b/datasets/google_cloud_release_notes/release_notes/release_notes_dag.py @@ -0,0 +1,47 @@ +# Copyright 2021 Google LLC +# +# 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. + + +from airflow import DAG +from airflow.contrib.operators import bigquery_to_bigquery + +default_args = { + "owner": "Google", + "depends_on_past": False, + "start_date": "2021-08-05", +} + + +with DAG( + dag_id="google_cloud_release_notes.release_notes", + default_args=default_args, + max_active_runs=1, + schedule_interval="0 5 * * *", + catchup=False, + default_view="graph", +) as dag: + + # Task to run a BQ to BQ operator + google_cloud_release_notes = bigquery_to_bigquery.BigQueryToBigQueryOperator( + task_id="google_cloud_release_notes", + source_project_dataset_tables=[ + "{{ var.json.google_cloud_release_notes.release_notes.source_project_dataset_table }}" + ], + destination_project_dataset_table="{{ var.json.google_cloud_release_notes.release_notes.destination_project_dataset_table }}", + impersonation_chain="{{ var.json.google_cloud_release_notes.service_account }}", + write_disposition="WRITE_TRUNCATE", + gcp_conn_id="google_cloud_release_notes_conn", + ) + + google_cloud_release_notes