⚑ Sangsakala Proxy 🏠 Home
Skip to content

About

Terraform module: terraform-google-document-ai-schema

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

☁️ Google Cloud Document AI Schema Terraform Module

Provisions a single Document AI schema (google_document_ai_schema) β€” a named metadata container β€” targeting hashicorp/google ~> 7.0 on Terraform >= 1.12.0.

Terraform Provider Module Version Module Type Resource Count Posture


🧩 Overview

  • 🏷️ Manages one Document AI schema (google_document_ai_schema) β€” a thin, named metadata container with a display_name, location, and labels.
  • πŸ“­ GENUINE FINDING: this resource has no nested schema-content block β€” confirmed via both the schema-JSON dump and the provider's own single live example. Do not confuse this with terraform-google-document-ai-warehouse-document-schema (a different product with a property_definitions structure).
  • 🧯 deletion_policy defaults to "PREVENT" β€” a house extension.

πŸ’‘ Why it matters: This is one of a small number of resources in this library where the Terraform surface is genuinely thinner than the resource name suggests β€” documenting that plainly prevents a caller from expecting a schema-content input that does not exist.


❀️ Support this project

If these Terraform modules have been helpful to you or your organization, I'd appreciate your support in any of the following ways:

Whether it's a star, a professional connection, or a coffee, every gesture helps keep these modules actively maintained and continually improving. Thank you for being part of the community!


πŸ—ΊοΈ Where this fits

flowchart LR
 SCHEMA["terraform-google-document-ai-schema\n(google_document_ai_schema)"]:::this

 classDef this fill:#4285F4,color:#ffffff,stroke:#333333
Loading

No sibling module cross-references this resource β€” stated explicitly rather than inventing a fictional consumer. Validated via the Mermaid Chart MCP before embedding.


🧬 What this builds

flowchart LR
 subgraph Inputs["Inputs"]
 I1["display_name, location"]
 I2["deletion_policy,\nlabels, timeouts"]
 end

 THIS["google_document_ai_schema.this"]:::this

 subgraph Outputs["Outputs"]
 O1["id, name"]
 O2["create_time, update_time,\nlabels surfaces"]
 end

 I1 --> THIS
 I2 --> THIS
 THIS --> O1
 THIS --> O2

 classDef this fill:#4285F4,color:#ffffff,stroke:#333333
Loading

Resource inventory: one keystone resource, google_document_ai_schema.this. No for_each-managed children β€” this is a standalone module (see SCOPE.md).


βœ… Provider / Versions

Terraform >= 1.12.0
hashicorp/google ~> 7.0
Provider block None β€” the caller configures google (ADC, WIF, or a service account key per our authentication model)

Schema notes that bite:

  • No nested schema-content block exists β€” a genuine finding, not an oversight.
  • labels IS supported β€” unlike terraform-google-looker-instance and terraform-google-document-ai-processor, this resource has a real labels surface.
  • No self_link.
  • All three create/update/delete timeouts are supported.

πŸ”‘ Required IAM Roles

  • roles/documentai.editor (or roles/documentai.admin) on the target project.

☁️ GCP Prerequisites

  • documentai.googleapis.com enabled.

πŸ“ Module Structure

terraform-google-document-ai-schema/
β”œβ”€β”€ providers.tf # required_providers + required_version β€” no provider {} block
β”œβ”€β”€ variables.tf # google_document_ai_schema.this schema β€” no schema-content block exists
β”œβ”€β”€ main.tf # google_document_ai_schema.this β€” the sole keystone resource
β”œβ”€β”€ outputs.tf # id, name β€” no self_link (none exists)
β”œβ”€β”€ README.md # this file
β”œβ”€β”€ SCOPE.md # lightweight standalone scope
└── examples/
 └── basic/ # smallest real call

βš™οΈ Quick Start

module "schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name = "loan-document-schema"
  location     = "us"
}

πŸ”Œ Cross-Module Contract

Consumes: none β€” this resource has no cross-references to other resources in this family.

Emits

Output Description
id Terraform-internal id
name Computed resource name
create_time / update_time RFC3339 timestamps
effective_labels / terraform_labels Label surfaces

πŸ“š Example Library

1 Β· Minimal schema
module "schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  location = "us"
}
2 Β· Named schema with a display name
module "loan_schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name = "loan-document-schema"
  location     = "us"
}
3 Β· EU location
module "eu_schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name = "eu-loan-schema"
  location     = "eu"
}
4 Β· Custom labels
module "labeled_schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name = "labeled-schema"
  location     = "us"

  labels = {
    environment = "prod"
    team        = "lending"
  }
}
5 Β· Relaxed deletion_policy for a scratch/dev schema
module "dev_schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name    = "dev-scratch-schema"
  location        = "us"
  deletion_policy = "DELETE"
}
6 Β· Custom timeouts
module "slow_schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name = "large-schema"
  location     = "us"

  timeouts = {
    create = "10m"
    update = "10m"
    delete = "10m"
  }
}
7 Β· Multiple schemas via a caller-side for_each
locals {
  schemas = ["loan-schema", "tax-form-schema", "id-document-schema"]
}

module "schemas" {
  source   = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"
  for_each = toset(local.schemas)

  display_name = each.value
  location     = "us"
}
8 Β· πŸ—οΈ End-to-end composition
module "processor" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"

  display_name = "loan-application-ocr"
  location     = "us"
  type         = "OCR_PROCESSOR"
}

module "schema" {
  source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-schema.git?ref=v1.0.0"

  display_name = "loan-document-schema"
  location     = "us"

  labels = {
    environment = "prod"
  }
}

output "processor_id" {
  value = module.processor.id
}

output "schema_id" {
  value = module.schema.id
}

ℹ️ These two modules have no direct Terraform cross-reference to each other (confirmed β€” neither resource's schema references the other); they are composed side-by-side in the same Document AI deployment rather than wired input-to-output.


πŸ“₯ Inputs

Required: location.

Grouped summary: identity (display_name, location), operations (deletion_policy, timeouts), universal tail (labels).

Full object schemas
variable "display_name" {
  type    = string
  default = null
}

variable "location" {
  type = string
}

variable "deletion_policy" {
  type    = string
  default = "PREVENT" # "DELETE" | "ABANDON" | "PREVENT"
}

variable "labels" {
  type    = map(string)
  default = {}
}

variable "timeouts" {
  type = object({
    create = optional(string)
    update = optional(string)
    delete = optional(string)
  })
  default = null
}

🧾 Outputs

Output Description Notes
id Terraform-internal id No self_link exists
name Computed resource name Always populated
create_time / update_time RFC3339 timestamps Always populated
effective_labels All labels present on the resource in GCP Always populated
terraform_labels Labels from Terraform config + provider defaults Always populated

🧠 Architecture Notes

  • No nested schema-content block. A genuine finding β€” this resource is a thin metadata container, not a document-type field definition.
  • labels IS supported here, unlike several Document AI/Looker siblings in this batch.
  • location/display_name are effectively force-new. No rename/re-region API exists.
  • deletion_policy default is a house extension. "PREVENT" is not the provider's own default.

🧱 Design Principles

Concern Secure default Opt-out (explicit)
Deletion guard deletion_policy = "PREVENT" (house extension) Caller sets "DELETE" or "ABANDON" explicitly

πŸš€ Runbook

cd terraform-google-document-ai-schema
terraform init -backend=false
terraform validate
terraform fmt -check

Pin ?ref=v1.0.0 β€” never a branch. This library is plan-only; a human applies from CI with valid ADC/WIF credentials.


πŸ§ͺ Testing

terraform validate/fmt -check confirm internal type/reference consistency and formatting only β€” they cannot catch GCP API-level rejections. A real terraform plan/apply against a live project is the only way to confirm this module's behavior end-to-end.


πŸ’¬ Example Output

$ terraform output

id = "projects/casey-prod/locations/us/schemas/abcdef0123456789"
name = "projects/casey-prod/locations/us/schemas/abcdef0123456789"

πŸ” Troubleshooting

Symptom Cause Fix
destroy fails with a deletion-policy error deletion_policy = "PREVENT" (this module's default) Apply once with deletion_policy = "DELETE" or "ABANDON", then run the destroy
Caller expects a schema-content/field-definition input and finds none This resource genuinely has no such block (see Architecture Notes) Use terraform-google-document-ai-warehouse-document-schema if property_definitions-style structured schema content is actually needed β€” a different product

πŸ”— Related Docs

About

Terraform module: terraform-google-document-ai-schema

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages