# Copyright 2025 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-bigtable
  annotations:
    config.kubernetes.io/local-config: "true"
spec:
  info:
    title: terraform-google-bigtable
    source:
      repo: https://github.com/GoogleCloudPlatform/terraform-google-bigtable.git
      sourceType: git
    version: 0.3.0
    actuationTool:
      flavor: Terraform
      version: ">= 1.3"
    description: {}
    icon: assets/icon.png
  content:
    examples:
      - name: basic
        location: examples/basic
  interfaces:
    variables:
      - name: project_id
        description: The ID of the project in which the resource belongs
        varType: string
        required: true
      - name: name
        description: The unique name of the Bigtable instance.
        varType: string
        required: true
      - name: display_name
        description: The human-readable display name of the Bigtable instance. Defaults to the instance name
        varType: string
      - name: deletion_protection
        description: Whether or not to allow Terraform to destroy the instance
        varType: bool
        defaultValue: true
      - name: storage_type
        description: The storage type to use. One of SSD or HDD. Defaults to SSD
        varType: string
        defaultValue: SSD
      - name: zones
        description: Zones of the Bigtable cluster.
        varType: |-
          map(object({
              zone         = string
              cluster_id   = string
              num_nodes    = optional(number)
              kms_key_name = optional(string)
              autoscaling_config = optional(object({
                min_nodes      = number
                max_nodes      = number
                cpu_target     = number
                storage_target = optional(number)
              }))
            }))
        defaultValue:
          zone1:
            autoscaling_config:
              cpu_target: 60
              max_nodes: 2
              min_nodes: 1
            cluster_id: cluster1
            zone: us-central1-a
          zone2:
            autoscaling_config:
              cpu_target: 60
              max_nodes: 2
              min_nodes: 1
            cluster_id: cluster2
            zone: us-west1-a
          zone3:
            autoscaling_config:
              cpu_target: 60
              max_nodes: 2
              min_nodes: 1
            cluster_id: cluster3
            zone: us-central1-c
      - name: labels
        description: labels associated to the Bigtable instance.
        varType: map(string)
        defaultValue: {}
      - name: tables
        description: Tables to created in the Bigtable instance.
        varType: |-
          map(object({
              table_name              = string
              split_keys              = optional(list(string))
              deletion_protection     = optional(string, "PROTECTED")
              change_stream_retention = optional(string, "0s")
              automated_backup_policy = optional(object({
                retention_period = string
                frequency        = string
              }))

              column_family = optional(map(object({
                family = string
                }))
              )
            }))
        defaultValue: {}
    outputs:
      - name: instance_id
        description: Bigtable instance id
        type: string
      - name: instance_name
        description: Bigtable instance name
        type: string
      - name: table_ids
        description: List of table being provisioned
        type:
          - list
          - string
  requirements:
    roles:
      - level: Project
        roles:
          - roles/bigtable.admin
          - roles/cloudkms.admin
          - roles/iam.serviceAccountAdmin
          - roles/serviceusage.serviceUsageAdmin
          - roles/resourcemanager.projectIamAdmin
    services:
      - cloudresourcemanager.googleapis.com
      - storage-api.googleapis.com
      - serviceusage.googleapis.com
      - bigtableadmin.googleapis.com
      - bigtable.googleapis.com
    providerVersions:
      - source: hashicorp/google
        version: ">= 3.53, < 7"
