Provisions a single Document AI processor (
google_document_ai_processor) β the OCR/form/ invoice/specialized document-extraction unit β targetinghashicorp/google ~> 7.0on Terraform>= 1.12.0.
- π Manages one Document AI processor β the GCP console/product name for
google_document_ai_processorβ the unit that runs a specific document-understanding task (OCR, form parsing, invoice extraction, and others). - π Supports CMEK (
kms_key_name), never defaulted to a specific key. - π§―
deletion_policydefaults to"PREVENT"β a house extension over the provider's own default; this resource has no separatedeletion_protectionboolean. - 𧬠First module in our Document AI domain slice β pairs with
terraform-google-document-ai-processor-default-versionto pin a serving version.
π‘ Why it matters: Document AI processors commonly ingest loan applications, tax forms, and other member financial documents. This module guards against an accidental
destroyby default and keeps CMEK an explicit, never-defaulted opt-in.
If these Terraform modules have been helpful to you or your organization, I'd appreciate your support in any of the following ways:
- β Star this repository to help others discover this Terraform module.
- π€ Connect with me on LinkedIn: linkedin.com/in/microsoftexpert
- β Buy me a coffee: buymeacoffee.com/microsoftexpert
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!
flowchart LR
KMS["terraform-google-kms-keyring\n(google_kms_crypto_key)"]:::neutral
PROC["terraform-google-document-ai-processor\n(google_document_ai_processor)"]:::this
VER["terraform-google-document-ai-processor-default-version\n(google_document_ai_processor_default_version)"]:::keystone
KMS -->|"crypto key name to kms_key_name (optional CMEK)"| PROC
PROC -->|"id to processor (required)"| VER
classDef this fill:#4285F4,color:#ffffff,stroke:#333333
classDef keystone fill:#174EA6,color:#ffffff,stroke:#333333
classDef neutral fill:#E8EAED,color:#202124,stroke:#999999
Validated via the Mermaid Chart MCP before embedding.
flowchart LR
subgraph Inputs["Inputs"]
I1["display_name,\nlocation, type"]
I2["kms_key_name,\ndeletion_policy, timeouts"]
end
THIS["google_document_ai_processor.this"]:::this
subgraph Outputs["Outputs"]
O1["id"]
O2["name"]
end
I1 --> THIS
I2 --> THIS
THIS --> O1
THIS --> O2
classDef this fill:#4285F4,color:#ffffff,stroke:#333333
Resource inventory: one keystone resource, google_document_ai_processor.this. No
for_each-managed children β this is a standalone module (see SCOPE.md).
| 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
labelsattribute β confirmed absent from the schema. - No
self_linkβidand the computednameare this resource's only identity forms. typeis not validated against a hardcoded enum β the schema defers to the API's ownFetchProcessorTypescall for the current list.- Only
create/deletetimeouts exist β noupdatetimeout. location/display_nameare effectively force-new β there is no rename/re-region API for an existing processor.
roles/documentai.editor(orroles/documentai.admin) on the target project.
documentai.googleapis.comenabled.- If
kms_key_nameis set: the KMS key must already exist, and the Document AI service agent needsroles/cloudkms.cryptoKeyEncrypterDecrypteron it.
terraform-google-document-ai-processor/
βββ providers.tf # required_providers + required_version β no provider {} block
βββ variables.tf # google_document_ai_processor.this schema
βββ main.tf # google_document_ai_processor.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
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"
}Consumes
| Input | Type | Source module |
|---|---|---|
kms_key_name |
string, optional |
terraform-google-kms-keyring |
Emits
| Output | Description |
|---|---|
id |
Terraform-internal id |
name |
Computed resource name |
1 Β· Minimal OCR processor
module "ocr" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "generic-ocr"
location = "us"
type = "OCR_PROCESSOR"
}2 Β· Form parser processor
module "form_parser" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "loan-form-parser"
location = "us"
type = "FORM_PARSER_PROCESSOR"
}3 Β· Invoice processor in the EU location
module "invoice_eu" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "eu-invoice-processor"
location = "eu"
type = "INVOICE_PROCESSOR"
}βΉοΈ
locationis deliberately not validated against a hardcoded allow-list β Document AI processing regions evolve independently of this module.
4 Β· CMEK via kms_key_name
module "cmek_processor" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "cmek-ocr"
location = "us"
type = "OCR_PROCESSOR"
kms_key_name = module.kms.crypto_key_ids["docai-cmek-key"]
}π Never default
kms_key_nameto a specific key β the caller always supplies it explicitly.
5 Β· Relaxed deletion_policy for a scratch/dev processor
module "dev_processor" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "dev-scratch-ocr"
location = "us"
type = "OCR_PROCESSOR"
deletion_policy = "DELETE"
}
β οΈ deletion_policy = "DELETE"removes this module's"PREVENT"guard β use only for genuinely disposable dev/test processors.
6 Β· Custom timeouts
module "slow_processor" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "large-batch-ocr"
location = "us"
type = "OCR_PROCESSOR"
timeouts = {
create = "20m"
delete = "20m"
}
}7 Β· Bank-statement parser
module "bank_statement" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "bank-statement-parser"
location = "us"
type = "BANK_STATEMENT_PROCESSOR"
}8 Β· ID document (identity verification) processor
module "id_proofing" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "member-id-verification"
location = "us"
type = "ID_PROOFING_PROCESSOR"
}9 Β· Contract/agreement parser
module "contract_parser" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "loan-agreement-parser"
location = "us"
type = "CONTRACT_PARSER_PROCESSOR"
}10 Β· Custom document extractor
module "custom_extractor" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
display_name = "custom-casey-extractor"
location = "us"
type = "CUSTOM_EXTRACTION_PROCESSOR"
}11 Β· Multiple processors via for_each in the caller's own root module
locals {
processors = {
ocr = "OCR_PROCESSOR"
form_parser = "FORM_PARSER_PROCESSOR"
bank_statement = "BANK_STATEMENT_PROCESSOR"
}
}
module "processors" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor.git?ref=v1.0.0"
for_each = local.processors
display_name = "casey-${each.key}"
location = "us"
type = each.value
}βΉοΈ This module has no natural child collection, so multi-processor fan-out is a caller-side
for_eachover the module block itself, not a composite module.
12 Β· ποΈ End-to-end composition
module "kms" {
source = "git::https://github.com/microsoftexpert/terraform-google-kms-keyring.git?ref=v1.0.0"
key_ring_name = "docai-keyring"
location = "us"
crypto_keys = {
"docai-cmek-key" = {}
}
}
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"
kms_key_name = module.kms.crypto_key_ids["docai-cmek-key"]
}
module "processor_default_version" {
source = "git::https://github.com/microsoftexpert/terraform-google-document-ai-processor-default-version.git?ref=v1.0.0"
processor = module.processor.id
version = "${module.processor.id}/processorVersions/stable"
}
output "processor_id" {
value = module.processor.id
}π‘ Wires
terraform-google-kms-keyring'scrypto_key_idsmap intokms_key_name, and this module's ownidinto the siblingterraform-google-document-ai-processor-default-versionmodule'sprocessorinput.
Required: display_name, location, type.
Grouped summary: identity (display_name, location, type), security (kms_key_name),
operations (deletion_policy, timeouts β no labels on this resource).
Full object schemas
variable "display_name" {
type = string
}
variable "location" {
type = string
}
variable "type" {
type = string
}
variable "kms_key_name" {
type = string
default = null
}
variable "deletion_policy" {
type = string
default = "PREVENT" # "DELETE" | "ABANDON" | "PREVENT"
}
variable "timeouts" {
type = object({
create = optional(string)
delete = optional(string)
})
default = null
}| Output | Description | Notes |
|---|---|---|
id |
Terraform-internal id | No self_link exists |
name |
Computed resource name | e.g. projects/{project}/locations/{location}/processors/{processor} |
- No
labels, noself_link. Both confirmed absent from this resource's schema. location/display_name/typeare effectively force-new. No rename/re-region/re-type API exists for an existing processor.deletion_policydefault is a house extension."PREVENT"is not the provider's own default; this resource has no separatedeletion_protectionboolean, so this is the sole guard.typehas no hardcoded enum. An invalid value is rejected by the API atapply, not caught atplan.
| Concern | Secure default | Opt-out (explicit) |
|---|---|---|
| CMEK | kms_key_name accepted, never defaulted to a specific key |
Caller supplies a key from terraform-google-kms-keyring |
| Deletion guard | deletion_policy = "PREVENT" (house extension) |
Caller sets "DELETE" or "ABANDON" explicitly |
cd terraform-google-document-ai-processor
terraform init -backend=false
terraform validate
terraform fmt -checkPin ?ref=v1.0.0 β never a branch. This library is plan-only; a human applies from CI with valid
ADC/WIF credentials.
terraform validate/fmt -check confirm internal type/reference consistency and formatting only
β they cannot catch GCP API-level rejections (an invalid type value, quota, or org policy). A
real terraform plan/apply against a live project is the only way to confirm this module's
behavior end-to-end.
$ terraform output
id = "projects/casey-prod/locations/us/processors/abcdef0123456789"
name = "projects/casey-prod/locations/us/processors/abcdef0123456789"
| 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 |
apply fails with an invalid processor type |
type is not validated against a hardcoded enum in this module |
Confirm the exact type string against the current FetchProcessorTypes API list before applying |
| CMEK apply fails with a permission error | Document AI service agent lacks roles/cloudkms.cryptoKeyEncrypterDecrypter on the key |
Grant the role and allow ~60 seconds for IAM propagation before retrying |
google_document_ai_processorβ Terraform Registry- Document AI β Google Cloud documentation
terraform-google-document-ai-processor-default-version(pins a serving version on this processor)terraform-google-kms-keyring(crypto key source for CMEK)- This module's
SCOPE.md