terraform-provider-stackgen

sg_app (Resource)

⚠️ Experimental — Manages a Guild app installation’s integration bindings and optional install config for a deployment-catalog application (e.g. sre for StackGen SRE Copilot).

The app must already be installed in the target org before this resource can apply. This resource calls PUT /api/v1/apps/{appName} — the same API the SRE app onboarding flow uses to attach Grafana, Datadog, GitHub, and other integrations.

Set provider workspace_id so bindings land in the same workspace as other Guild resources.

Set bootstrap_discovery = true on the sre app to run POST /app/sre/api/discovery/runs after bindings (same as finishing onboarding in the UI).

Example Usage

# When to use: Bind Guild integrations to an already-installed deployment-catalog
# app (catalog slug "sre" for StackGen SRE Copilot). Use this after the app is
# installed in the org — this resource does NOT install the app.
#
# Prerequisites:
#   - Provider workspace_id so bindings land in the correct org
#   - App already installed (UI or catalog install flow)
#   - Integration names must exist in the org (sg_guild_integration or pre-provisioned)
#
# Related: sg_sre_alert_webhook (alert ingest), data.sg_app / data.sg_apps (lookup),
# sg_guild_integration (create integrations before binding).
#
# Requires provider >= 0.1.26.
resource "sg_app" "sre" {
  app_name = "sre"
  integrations = [
    "example-grafana",
    "example-datadog",
    "example-slack",
  ]
  config = {
    setup_type = "workspace"
  }
}
# When to use: Same as resource.tf, but finish SRE onboarding the same way the UI
# "connect stack" flow does — start discovery after bindings so the app learns
# labels, namespaces, and services before the first incident.
#
# Prerequisites: provider workspace_id; catalog slug "sre"; integrations already exist.
# Set discovery_skip_if_exists = true in CI so re-applies do not start duplicate runs.
#
# Requires provider >= 0.1.26.
resource "sg_app" "sre_with_discovery" {
  app_name     = "sre"
  integrations = ["example-grafana", "example-datadog"]

  bootstrap_discovery            = true
  discovery_skip_if_exists       = true
  discovery_poll_timeout_seconds = 600
  discovery_setup_wait_attempts  = 30
}

Import

Import an existing sg_app using its catalog app name:

terraform import sg_app.example 'sre'

Operational notes

Install the catalog app and create the referenced Guild integrations before managing its binding set. integrations replaces the full set on apply. attached_workflows and workflow_assignments are independent: omit either to leave it unmanaged, or set [] to clear it. Assignments must reference app-declared purposes and approved, operator-owned workflows; at most one default per purpose.

Schema

Required

Optional

Read-Only

Nested Schema for workflow_assignments

Required:

Optional:

Nested Schema for workflow_purposes

Read-Only: