Skip to main content

From Waypoint to Terraform Developer Portal: Designing an Application Upgrade Contract

·

12 min read

Listen to this article

Matthew · Amazon Polly

0:00
0:00

A platform team adds a required deployment-ring input to a shared module. Newly created applications receive the field, while existing applications still carry the previous inputs. An agent preparing an upgrade fills the missing value with a plausible default. The plan succeeds, but the application has entered a rollout cohort its owner never selected.

This is an illustrative failure, not a reported incident. It exposes two different questions: can the new module evaluate the application's inputs, and is the resulting change acceptable for that application? A template catalogue answers neither completely. The upgrade needs an explicit compatibility decision followed by a review of the actual resource changes.

The design developed here uses two checks: a module-level contract revision and a deliberately narrow saved-plan gate. The revision prevents accidental adoption of a changed interface. The gate rejects replacement, deletion and unexpected resource addresses. Neither confers authorization; that remains with the execution system and the application owner. The useful result is an upgrade that is mechanically reviewable before any infrastructure change occurs.

Where the portal stops and application adoption begins

HCP Waypoint's documentation now points toward Terraform Developer Portal as its capabilities transition. This is separate from the legacy OSS Waypoint repository, archived in January 2024. TDP is a hosted HCP Terraform capability, not a new release of that archived build-and-deploy tool. HCP Waypoint direction, OSS repository.

As checked on 25 November 2026, TDP remains public beta and its documentation advises against production use. The documented application workflow requires HCP Terraform Standard or higher. A deployed application has its own workspace. Module-version changes produce update notifications; application owners initiate adoption and supply new inputs. Application workflow.

Template editing has different semantics: changes apply to future applications rather than rewriting existing deployments. That distinction makes the module release, template configuration and application upgrade separate review events. Template management.

The implementation below tests the module-and-plan portion locally with Terraform 1.13.3 and Python 3. It uses actual Terraform plans and state, without a cloud account or downloaded provider. It does not demonstrate a live TDP upgrade or a Waypoint migration. The documented portal steps later in the article are an integration procedure for a non-production environment.

Make the changed interface explicit

Consider a service module whose first revision accepts an application name. Revision two adds a rollout cohort. Giving the new input a default would simplify adoption, but it would also encode a decision on behalf of every existing application. For a cohort that controls deployment timing, forcing the owner to choose is the preferable failure mode.

The contract number describes this compatibility decision, not the module's package version. Patch releases that preserve the interface need not change it. A new required input, changed interpretation or materially different rollout behaviour merits a new contract revision and migration instructions. This is a proposed platform convention; it is not a built-in TDP versioning feature.

Create v1/main.tf:

terraform {
  required_version = "= 1.13.3"
}
variable "developer_portal_application" {
  type = string
}
variable "accepted_contract" {
  type = number
}
resource "terraform_data" "application" {
  input = {
    application = var.developer_portal_application
    contract = 1
  }
  lifecycle {
    precondition {
      condition = var.accepted_contract == 1
      error_message = "Application inputs have not adopted contract 1."
    }
  }
}
output "application" {
  value = terraform_data.application.output
}

Create v2/main.tf:

terraform {
  required_version = "= 1.13.3"
}
variable "developer_portal_application" {
  type = string
}
variable "accepted_contract" {
  type = number
}
variable "deployment_ring" {
  type = string
  validation {
    condition = contains(["canary", "standard"], var.deployment_ring)
    error_message = "deployment_ring must be canary or standard."
  }
}
resource "terraform_data" "application" {
  input = {
    application = var.developer_portal_application
    contract = 2
    ring = var.deployment_ring
  }
  lifecycle {
    precondition {
      condition = var.accepted_contract == 2
      error_message = "Application inputs have not adopted contract 2."
    }
  }
}
output "application" {
  value = terraform_data.application.output
}

The terraform_data resource provides a real stateful lifecycle without provisioning remote infrastructure. It stores the example's application metadata; it is not a deployed service or a claim about a cloud resource's replacement behaviour. Built-in resource reference.

The second module rejects an old contract number through a resource precondition. Because that condition depends only on supplied inputs, the rejection can occur during planning. Preconditions that depend on values unknown until apply have different timing, so this result must not be generalized to every expression. Lifecycle conditions.

The number is intentionally not called an approval token. Anyone able to change the inputs can change it. Its purpose is to prevent silent interface adoption, not to authenticate an owner or constrain a hostile actor. Approval belongs in permissions and the run workflow, outside an agent-editable variable.

Reproduce the failed upgrade before accepting the successful one

Create application/main.tf alongside the two module directories:

module "app" {
  source                       = "../v1"
  developer_portal_application = "catalog-api"
  accepted_contract            = 1
}
```

From the parent directory, initialize and create the local baseline:

terraform -chdir=application init -input=false
terraform -chdir=application apply -input=false -auto-approve

Replace the module call with the following, retaining the application directory and its state:

module "app" {
  source                       = "../v2"
  developer_portal_application = "catalog-api"
  accepted_contract            = 1
  deployment_ring              = "canary"
}
terraform -chdir=application init -input=false
terraform -chdir=application plan -input=false

This plan must fail: adding a valid ring does not satisfy the contract transition. A separate attempt with deployment_ring omitted must also fail, now because a required input is missing. These failures distinguish incomplete configuration from a complete configuration that has not acknowledged the new interface.

After reviewing the new input and migration instructions, set accepted_contract = 2. Save the resulting plan instead of applying immediately:

terraform -chdir=application plan -input=false -out=upgrade.tfplan

For this laboratory reproduction, the explicit -auto-approve above creates only the initial local metadata resource. It is not the recommended approval setting for shared infrastructure. The upgrade path deliberately separates planning from execution.

Inspect the plan that will actually execute

Input checks cannot detect every dangerous change. A module author can accidentally change an address, add a resource or introduce replacement semantics while preserving the inputs. A second check therefore examines Terraform's machine-readable plan. The JSON format exposes resource addresses and action sequences, including replacement actions containing both creation and deletion. Plan representation.

Save this complete gate as gate.py in the parent directory:

import json, subprocess, sys
from pathlib import Path

plan = Path(sys.argv[1]).resolve()
raw = subprocess.run(["terraform", "show", "-json", str(plan)],
                     check=True, capture_output=True, text=True)
p = json.loads(raw.stdout)
if p.get("format_version") != "1.2" or p.get("terraform_version") != "1.13.3":
    raise SystemExit("REJECT: untested plan format or CLI version")
changes = p.get("resource_changes")
if not isinstance(changes, list) or not changes:
    raise SystemExit("REJECT: missing resource changes")
expected = "module.app.terraform_data.application"
if len(changes) != 1 or changes[0].get("address") != expected:
    raise SystemExit("REJECT: unexpected resource address set")
change = changes[0]["change"]
if change.get("actions") not in [["update"], ["no-op"]]:
    raise SystemExit("REJECT: only an in-place upgrade is allowed")
after = change.get("after") or {}
if after.get("input", {}).get("contract") != 2:
    raise SystemExit("REJECT: unexpected contract")
print("PASS: bounded contract-2 plan; owner authorization still required")

Run it from the initialized application directory:

cd application
python3 ../gate.py upgrade.tfplan

This intentionally small allowlist admits only the single expected resource and an in-place change or no-op. It rejects an initial creation because the baseline should already exist. A missing change list, an unfamiliar CLI/schema version or an unexpected address is a reason to stop and inspect, not to infer safety. The exact version pin makes future upgrades of the gate an explicit maintenance task.

Generate a real counterexample without applying it:

terraform plan -input=false   -replace=module.app.terraform_data.application -out=replace.tfplan
python3 ../gate.py replace.tfplan

The gate must exit nonzero. A successful Terraform plan means that Terraform can propose a transition; it does not mean that the transition satisfies the platform's deployment policy. For a real module, resource-specific allowlists and attribute-level rules would replace this single-resource policy. Allowing all updates would still miss hazardous in-place mutations, such as opening network access or changing a critical destination.

The gate invokes terraform show on the saved binary plan itself rather than trusting a separately supplied JSON file. The runner still needs to protect the artifact and gate code from modification between review and apply. A digest can bind the review record to the file, but a digest is not a signature or an owner identity. Saved plans can contain sensitive data, so artifact access and retention require the same care as the underlying configuration. Saved-plan handling.

After the gate and owner review accept the original plan:

terraform apply -input=false upgrade.tfplan
terraform plan -input=false -out=noop.tfplan
python3 ../gate.py noop.tfplan

Reference workflow: the agent may propose inputs and explain the diff; deterministic checks and owner authorization govern execution.

What the experiment established

The local run exercised six plan scenarios. Missing input and old-contract attempts failed. The intended revision-two update passed. Forced replacement and destruction plans were rejected. After applying the approved update, a no-op plan passed. The missing-input, old-contract and forced-replacement attempts left the original state bytes unchanged; the successful update retained the resource ID. The accompanying reproduction captures the commands and outputs.

Those observations establish the behaviour of this module and gate with Terraform 1.13.3. They do not establish TDP's approval behaviour, a cloud provider's replacement semantics or end-to-end application health. A service migration needs an additional application-level check—such as a real request against the upgraded service—before the rollout is considered healthy.

An AI assistant has a useful but limited role here: explain the interface delta, identify missing owner decisions and summarize the bounded plan. It should not invent a deployment ring, modify the gate to obtain a pass or treat an earlier approval as authority for a newly generated plan. A failed plan is actionable evidence for the developer workflow, not a reason to widen permissions automatically.

Carry the tested module into a non-production portal workflow

For a TDP trial, publish each module revision through the organization's private registry and enable no-code provisioning. The module belongs at the repository root; external provider configuration and credentials must be designed for the generated workspace. The local ../v2 source is a reproduction convenience, not a registry publishing configuration. No-code module requirements.

Create a template from that no-code module. Declare developer_portal_application so TDP can supply the application name. Configure the contract and ring inputs deliberately, and put the migration instructions beside the template. Exposing a variable in the form does not grant change authority. Template configuration.

For existing applications, follow the update notification, supply required inputs and review the resulting run. The current instructions include both a manual confirmation step and subsequent automatic-apply wording. Until the actual workspace settings and flow are verified, no universal approval guarantee follows from that page. The Python gate here is a local release qualification tool; it is not automatically installed in TDP. Equivalent hosted enforcement requires a separately configured policy or run integration. Documented update sequence.

The adoption record should bind the application identifier, installed module version, target version, selected inputs and reviewed run. These fields answer different questions during recovery. A successful module test says something about the reusable artifact; a successful application run says something about one instance. Combining them into a single green status makes it difficult to distinguish an unattempted upgrade from an unsuccessful one.

The release pipeline also needs a clear division of credentials. Module maintainers publish the implementation and its migration instructions. A qualification runner evaluates disposable instances. Application execution uses the credentials associated with its own workspace. Giving an explanatory agent the publishing and applying identities would undermine the separation the workflow is intended to create. The agent can attach evidence to a proposed upgrade while the trusted runner remains responsible for the plan artifact and enforcement code.

Failures should surface as specific developer actions: supply the new input, review a changed contract, or escalate an unexpected replacement. A generic “upgrade failed” status transfers investigation back to the platform team and erodes the benefit of self-service. Retaining the failing rule and relevant resource address makes the next decision concrete without exposing the complete state to the assistant.

Central forced adoption can minimize version divergence, but it also couples a module release to every application's readiness. Owner-led adoption preserves release autonomy at the cost of tracking lag. For this scenario, staged adoption is preferable: qualify the module, upgrade a non-production canary, examine its application-level result, then expand the cohort. The useful metric is successful adoption by contract revision, with failed and deferred applications separately visible.

The compatibility marker should also be visible in the application inventory. Otherwise a release team can count module versions without noticing that two versions accept the same contract, or that an application has deferred a required decision. Separating package version from accepted contract makes migration reporting more precise and helps assign follow-up to the application owner. It does not remove the need to inspect the actual planned resource changes.

Rollback also needs a plan. An old module version is not automatically a valid inverse of a completed change. Before expansion, determine whether the previous configuration produces a safe recovery plan and whether data changes are reversible. Where they are not, prepare a forward repair or a tested restoration procedure instead of promising that a version selector provides recovery.

The local demonstration can be cleaned up with terraform destroy -auto-approve from application; it contains only the metadata resource. Retain the evidence needed for the article, then remove local plan and state files according to the lab's retention policy.

A platform upgrade becomes dependable when interface adoption, resource changes and application health are evaluated separately. The portal improves how an application owner reaches that workflow. The implementation establishes which transition is acceptable—and produces evidence when it is not.

Comments (2)

Discuss on Hashnode

The migration detail matters most for small teams — existing apps keep the old inputs, so the gate has to reject them explicitly, not just accept the new ones. Logging which ring each app is on would also catch the one app that never got the new field.

Reproducing the failed upgrade before the successful one is the part I'd steal — proving the gate actually rejects the old contract and the missing input makes the acceptance test mean something, instead of just trusting a green plan.