GoogleCloudbuildTrigger class final

Factory wrapper for google_cloudbuild_trigger (provider hashicorp/google ~> 7.0).

A Cloud Build trigger fires a build in response to a source event (SCM push / pull request, Pub/Sub message, webhook, or manual run). The resource has two competing repository-connection forms that callers must pick between:

  1. v1 (legacy) — point the trigger at a GitHub App / Bitbucket Server installation directly via the inline github or bitbucketServerTriggerConfig block. The trigger watches the SCM webhook delivered through the legacy Cloud Build first-party integration. Recommended only for installs that pre-date the second-generation connection (i.e. existing GitHub App users).
  2. v2 (modern, 2024+) — supply repositoryEventConfig referring to a cloudbuildv2_repository (which in turn pins a cloudbuildv2_connection). The v2 form supports the full matrix of providers — GitHub, GitHub Enterprise, GitLab Self-Managed, Bitbucket Data Center, Bitbucket Cloud — through a single uniform Repo API surface. Recommended for new builds.

Each trigger picks exactly one of: github / bitbucketServerTriggerConfig / repositoryEventConfig / developerConnectEventConfig / pubsubConfig / webhookConfig / triggerTemplate / sourceToBuild. The first six wire up an event source; triggerTemplate is the legacy Cloud Source Repositories form; sourceToBuild declares a manual / Pub/Sub / Webhook-invoked build's source explicitly.

Build content is supplied in one of three ways (exactly one):

  • filename — path to an in-repo cloudbuild.yaml. Use with triggerTemplate or github.
  • gitFileSource — fetch the build config from an arbitrary repo / ref. Use with Pub/Sub, Webhook, Manual, or v2 triggers.
  • build — inline build steps + options, fully defined in HCL.

Required identity:

  • localName: Terraform local name (the address segment after google_cloudbuild_trigger.).

Optional but commonly set:

  • location: Cloud Build region (e.g. 'asia-northeast1'). Defaults to 'global'. Repository-event triggers MUST live in the same region as their cloudbuildv2_repository.
  • name: trigger name (must be unique within the project). When omitted the API assigns one.
  • service_account: Cloud Build service account to run the build as. Format: 'projects/{PROJECT_ID}/serviceAccounts/{SA_EMAIL}'. When null the legacy [PROJECT_NUM]@cloudbuild.gserviceaccount.com SA is used.

Example 1 — v1 form (GitHub App push to main, runs in-repo

cloudbuild.yaml):

final pushTrigger = GoogleCloudbuildTrigger(
  localName: 'push_main',
  name: TfArg.literal('push-main'),
  location: TfArg.literal('asia-northeast1'),
  filename: TfArg.literal('cloudbuild.yaml'),
  github: const CloudBuildTriggerGithub(
    owner: TfArg.literal('myorg'),
    name: TfArg.literal('my-repo'),
    push: CloudBuildTriggerPushFilter(
      branch: TfArg.literal('^main\$'),
    ),
  ),
);

Example 2 — v2 form (Repository event config, pull-request gate

against a cloudbuildv2_repository sibling — controller wires the real id at quickstart-materialize time):

final prTrigger = GoogleCloudbuildTrigger(
  localName: 'pr_gate',
  name: TfArg.literal('pr-gate'),
  location: TfArg.literal('asia-northeast1'),
  serviceAccount: TfArg.literal(
    'projects/my-project/serviceAccounts/cb-runner@my-project.iam.gserviceaccount.com',
  ),
  filename: TfArg.literal('cloudbuild.yaml'),
  repositoryEventConfig: CloudBuildTriggerRepositoryEventConfig(
    repository: TfArg.literal(r'${var.cloudbuildv2_repository_id}'),
    pullRequest: const CloudBuildTriggerPullRequestFilter(
      branch: TfArg.literal('^main\$'),
      commentControl: TfArg.literal(
        CloudBuildTriggerCommentControl.commentsEnabled,
      ),
    ),
  ),
);

Naming convention: ALL nested helper types are prefixed CloudBuildTrigger... (e.g. CloudBuildTriggerGithub, CloudBuildTriggerPushFilter, CloudBuildTriggerBuild, CloudBuildTriggerBuildStep) to avoid colliding with sibling resources such as GoogleCloudbuildWorkerPool.

The build sub-tree is sprawling — the schema reaches several levels deep through source.repo_source.substitutions, step.volumes, artifacts.maven_artifacts, available_secrets, etc. The wrapper models the commonly-used surface as typed helpers (CloudBuildTriggerBuild, CloudBuildTriggerBuildStep, CloudBuildTriggerBuildOptions) and exposes the deeper / rarely-set sub-blocks via the CloudBuildTriggerBuild.advancedExtra escape hatch — pass a raw Map<String, Object?> keyed by the Terraform block name when you need them. See the per-class doc for the exact escape-hatch key.

Cross-resource references:

  • build.options.pool accepts a google_cloudbuild_worker_pool id (typically passed as var.cloudbuild_worker_pool_id from a sibling GoogleCloudbuildWorkerPool).
  • repositoryEventConfig.repository accepts a google_cloudbuildv2_repository id (typically passed as var.cloudbuildv2_repository_id).

Composition pattern: extends Resource<$GoogleCloudbuildTrigger> for runtime behavior.

Constructors

GoogleCloudbuildTrigger({required String localName, TfArg<String>? name, TfArg<String>? location, TfArg<String>? description, TfArg<List<String>>? tags, TfArg<bool>? disabled, TfArg<String>? serviceAccount, TfArg<CloudBuildTriggerIncludeBuildLogs>? includeBuildLogs, TfArg<String>? filter, TfArg<Map<String, String>>? substitutions, TfArg<List<String>>? includedFiles, TfArg<List<String>>? ignoredFiles, TfArg<String>? filename, CloudBuildTriggerGitFileSource? gitFileSource, CloudBuildTriggerSourceToBuild? sourceToBuild, CloudBuildTriggerTriggerTemplate? triggerTemplate, CloudBuildTriggerGithub? github, CloudBuildTriggerBitbucketServerTriggerConfig? bitbucketServerTriggerConfig, CloudBuildTriggerRepositoryEventConfig? repositoryEventConfig, CloudBuildTriggerDeveloperConnectEventConfig? developerConnectEventConfig, CloudBuildTriggerPubsubConfig? pubsubConfig, CloudBuildTriggerWebhookConfig? webhookConfig, CloudBuildTriggerApprovalConfig? approvalConfig, CloudBuildTriggerBuild? build, TfArg<String>? project, LifecycleOptions? lifecycle, List<DependencyTarget>? dependsOn})

Properties

$sensitiveFields Set<String>
Field names that are @Sensitive per the IR-derived per-resource constant. Curated factories override with a baked-in static const Set<String> (file-private in v0.5+).
no setter
argMap Map<String, TfArg?>
Argument-name → TfArg map. Keys are snake_case (Terraform JSON name). Synth emits these keys directly; the factory is responsible for the camelCase → snake_case translation at construction time.
finalinherited
createTime → TfRef<String>
Reference to the create_time attribute (RFC 3339 timestamp). Populated after apply.
no setter
dependsOn List<DependencyTarget>?
Optional depends_on = [...]. Each entry is a DependencyTarget — either a wholesale resource (rendered as bare address) or an explicit TfRef (rendered via bareAddress).
finalinherited
hashCode int
The hash code for this object.
no setterinherited
id → TfRef<String>
Reference to id attribute. The id format is projects/{project}/locations/{location}/triggers/{trigger_id} for regional triggers, or projects/{project}/triggers/{trigger_id} for the legacy global location.
no setter
kind → ResourceKind
Always ResourceKind.resource. Overridden by Data.
no setterinherited
lifecycle → LifecycleOptions?
Optional lifecycle { ... } block.
finalinherited
localName String
User-supplied local name within a Stack.
finalinherited
nameRef → TfRef<String>
Reference to name attribute.
no setter
provider → ProviderBinding?
Optional explicit provider binding. Only the type is referenced here; the concrete Provider class lives in terradart_google (provider classes are defined per-provider, outside the core runtime).
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
terraformType String
Terraform resource type, e.g. google_pubsub_topic.
finalinherited
tfAddress String
no setterinherited
triggerId → TfRef<String>
Reference to the server-assigned trigger_id — the stable identifier in the API path. Populated after apply.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

$tfType → const String