# Copyright 2024 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.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
  name: terraform-google-bigquery-data-warehouse
  annotations:
    config.kubernetes.io/local-config: "true"
spec:
  info:
    title: terraform-google-bigquery-data-warehouse
    source:
      repo: https://github.com/terraform-google-modules/terraform-google-bigquery
      sourceType: git
      dir: /modules/data_warehouse
    version: 8.1.0
    actuationTool:
      flavor: Terraform
      version: ">= 0.13"
    description: {}
    icon: assets/data_warehouse_icon_v1.png
    deploymentDuration:
      configurationSecs: "120"
      deploymentSecs: "420"
    costEstimate:
      description: cost of this solution is $0.65
      url: https://cloud.google.com/products/calculator/#id=857776c6-49e8-4c6a-adc5-42a15b8fb67d
    cloudProducts:
      - productId: search_BIGQUERY_SECTION
      - productId: WORKFLOWS_SECTION
      - productId: STORAGE_SECTION
      - productId: ai-platform
      - productId: LOOKER_STUDIO_SECTION
        pageUrl: lookerstudio.google.com
        isExternal: true
      - productId: CLOUD_DMS_SECTION
      - productId: FUNCTIONS_SECTION
      - productId: DATAFORM_SECTION
  content:
    architecture:
      diagramUrl: www.gstatic.com/pantheon/images/solutions/data-warehouse-architecture_v6.svg
      description:
        - Data lands in a Cloud Storage bucket.
        - Cloud Workflows facilitates the data movement.
        - Data is loaded into BigQuery as a BigLake table.
        - Views of the data are created in BigQuery using stored procedures
        - Dashboards are created from the data to perform more analytics.
        - BigQuery ML calls the generative AI capabilities of Vertex AI to summarize the analysis.
        - Cloud Functions creates notebooks with additional learning content.
    documentation:
      - title: Create a Data Warehouse
        url: https://cloud.google.com/architecture/big-data-analytics/data-warehouse
      - title: Learn about BigQuery
        url: https://cloud.google.com/bigquery/docs/introduction
    examples:
      - name: basic_bq
        location: examples/basic_bq
      - name: basic_view
        location: examples/basic_view
      - name: data_warehouse
        location: examples/data_warehouse
      - name: multiple_tables
        location: examples/multiple_tables
      - name: scheduled_queries
        location: examples/scheduled_queries
  interfaces:
    variables:
      - name: project_id
        description: Google Cloud Project ID
        varType: string
        required: true
      - name: region
        description: Google Cloud Region
        varType: string
        required: true
      - name: dataform_region
        description: Region that is used to deploy Dataform resources. This does not limit where resources can be run or what region data must be located in.
        varType: string
      - name: text_generation_model_name
        description: Name of the BigQuery ML GenAI remote model that connects to the LLM used for text generation
        varType: string
        defaultValue: text_generate_model
      - name: labels
        description: A map of labels to apply to contained resources.
        varType: map(string)
        defaultValue:
          data-warehouse: true
      - name: enable_apis
        description: Whether or not to enable underlying apis in this solution.
        varType: string
        defaultValue: true
      - name: force_destroy
        description: Whether or not to protect BigQuery resources from deletion when solution is modified or changed.
        varType: string
        defaultValue: true
      - name: deletion_protection
        description: Whether or not to protect GCS resources from deletion when solution is modified or changed.
        varType: string
        defaultValue: false
      - name: create_ignore_service_accounts
        description: Whether or not to ignore creation of a service account if an account of the same name already exists
        varType: string
        defaultValue: true
    outputs:
      - name: bigquery_editor_url
        description: The URL to launch the BigQuery editor with the sample query procedure opened
      - name: ds_friendly_name
        description: Dataset name
      - name: lookerstudio_report_url
        description: The URL to create a new Looker Studio report displays a sample dashboard for the e-commerce data analysis
      - name: neos_tutorial_url
        description: The URL to launch the in-console tutorial for the EDW solution
      - name: raw_bucket
        description: Raw bucket name
  requirements:
    roles:
      - level: Project
        roles:
          - roles/bigquery.admin
          - roles/cloudkms.cryptoKeyEncrypterDecrypter
          - roles/owner
    services:
      - cloudkms.googleapis.com
      - cloudresourcemanager.googleapis.com
      - bigquery.googleapis.com
      - bigquerystorage.googleapis.com
      - bigqueryconnection.googleapis.com
      - serviceusage.googleapis.com
      - iam.googleapis.com
    providerVersions:
      - source: hashicorp/google
        version: ">= 5.39, < 7"
