Skip to content

Test Tools Migration (Forge v2 to v3)

This guide walks through migrating a Forge 2.x test-tools repository to Forge 3.0. The migration covers Terraform restructuring, variable casing updates, and pipeline updates for test user management and non-prod role assignments.

â„šī¸ What is a test-tools repository? These repositories manage developer utilities for testing:

  • Non-prod role assignments - Assign yourself to business roles in non-production environments
  • External test users - Create and manage Okta test users for external authentication
  • Token generation - Generate OAuth 2.0 JWT tokens for API testing with tools like Postman or Swagger

📋 Prerequisites

  • No SDK installation required — Test-tools repositories only use Terraform (no .NET or Node.js)

  • Access to Pulumi Cloud — Verify you can reach the saif-corp organization. The pipelines create and use the stacks {project_id}_np-role-assignment and {project_id}_ext-test-users on the Pulumi Cloud Terraform backend (tf.pulumi.com)

  • Okta service account credentials — Required for deployment of the external test users pipeline only (these are pipeline secrets). Not needed for non-prod role assignment, which is Entra ID only.

- [ ] State copied and verified — Existing HCP Terraform state is in the destination stacks, per Move State Before the First Pipeline Run, before you run the new pipelines

Overview of Changes

The migration updates test-tools repositories to align with Forge 3.0 conventions:

Area Change
Folder structure Verify -corp suffix exists (rename if needed)
Backend Replace the HCP Terraform cloud block with tf.pulumi.com / saif-corp
Module sources Install from tf.pulumi.com/saif-corp/... at >= 3.7.0, < 4.0.0
Bootstrap Delete infra/test-user-maint-external/bootstrap/
YAML casing External test users: UserMap → user_map (non-prod roles unchanged)
Pipeline templates Update to v3 templates with refs/heads/releases/v3 reference

🚚 Move State Before the First Pipeline Run

Changing the cloud block hostname does not copy existing HCP Terraform state into the Pulumi stacks. With empty destination state, Terraform plans to create the existing users and memberships again, and Step A cannot clean up the old Okta resources.

Before the first run of the new pipelines, copy the existing HCP Terraform state into the destination stacks by following Step 7 of the TFC to ESC credentials guide. Keep the old pipelines and workspaces frozen until the copy is verified, so the old runners cannot apply after the copy.

Root Destination stack
infra/np-role-assignment-corp {project_id}_np-role-assignment
infra/test-user-maint-external/okta {project_id}_ext-test-users
  • Back up the source state before you copy it.
  • Verify the destination state (for example with terraform state list and a clean terraform plan) before you unfreeze anything.
  • The bootstrap workspaces (bootstrap-<app>-ext-test-users) are dropped, so they need no transfer.
  • New roots with no existing HCP Terraform state and roots already on Pulumi need no transfer.

1ī¸âƒŖ Verify Folder Structure

Check your current folder structure.

Expected Structure

infra/
├── np-role-assignment-corp/    # Non-prod role assignments
│   ├── my-roles.yml
│   └── okta-nprole-assignment.generated.tf
└── test-user-maint-external/   # External test users
    └── okta/
        ├── external-test-users.generated.tf
        └── my-test-users.yml

Checklist

Run these commands from your repository root:

  • If your folder is named np-role-assignment/, rename it to np-role-assignment-corp/:
# Only run if you have np-role-assignment/ instead of np-role-assignment-corp/
git mv ./infra/np-role-assignment/ ./infra/np-role-assignment-corp/

â„šī¸ Note: Most test-tools repositories already have the -corp suffix. Only older repos need this rename.


2ī¸âƒŖ Module Version Updates

Update Terraform modules to version 3.0 and update external test user YAML structure.

Non-Prod Role Assignment Updates

  • Update infra/np-role-assignment-corp/okta-nprole-assignment.generated.tf

Before

locals {
  yaml     = yamldecode(file("./my-roles.yml"))
  username = local.yaml.Username
  roles    = local.yaml.Roles
}

module "saif-nproles" {
  source   = "app.terraform.io/SAIFCorp/saif-nproles/okta"
  version  = ">=1.0.0, <2.0.0"
  Username = local.username
  Roles    = local.roles
}

Migrate in two steps

The old saif-nproles/okta module and the new np-roles/okta module are different module addresses in Terraform state (different local names), so swapping the source is a destroy-and-recreate, not an in-place upgrade. If your workspace's old module provisioned real Okta-side resources, Terraform needs the Okta provider still configured to destroy them cleanly. Bump the module version first while keeping the Okta provider configured in place, apply, and confirm no Okta resources remain before removing the provider in a follow-up step.

This two-step migration only applies to existing v2 repos that already have an Okta provider in Terraform state. Repositories scaffolded fresh from the current saif-test-tools template have no Okta provider or okta_* variables for non-prod role assignment at all — Step B is already the default for new repos, so there's nothing to migrate.

Step A - Bump the module version only

Keep the Okta provider block, replace its arguments and the okta_* variables with the empty provider "okta" {} (the pipeline supplies the credentials as OKTA_* environment variables from the saif-corp/saif/test Pulumi ESC environment), and change the module block:

terraform {
  cloud {
    hostname     = "tf.pulumi.com"
    organization = "saif-corp"
  }

  required_providers {
    okta = {
      source = "okta/okta"
    }
  }
}

provider "okta" {}

locals {
  yaml     = yamldecode(file("./my-roles.yml"))
  username = local.yaml.Username
  roles    = local.yaml.Roles
}

module "np-roles" {
  source   = "tf.pulumi.com/saif-corp/np-roles/okta"
  version  = ">= 3.7.0, < 4.0.0"
  Username = local.username
  Roles    = local.roles
}

Apply this change, then run terraform state list and confirm no resources remain under the old module.saif-nproles address. Let the pipeline run to completion before proceeding.

Step B — Remove the Okta provider (follow-up PR)

Once Step A has applied cleanly, open a separate PR that removes the Okta provider block and okta_* variables.

Full Updated File:

terraform {
  cloud {
    hostname     = "tf.pulumi.com"
    organization = "saif-corp"
  }
}

locals {
  yaml     = yamldecode(file("./my-roles.yml"))
  username = local.yaml.Username
  roles    = local.yaml.Roles
}

module "np-roles" {
  source   = "tf.pulumi.com/saif-corp/np-roles/okta"
  version  = ">= 3.7.0, < 4.0.0"
  Username = local.username
  Roles    = local.roles
}

â„šī¸ Note: The cloud block has no workspaces block because the pipeline selects the stack ({project_id}_np-role-assignment) through TF_WORKSPACE. The np-roles/okta module provisions Entra ID business-role group membership internally — no Okta provider or okta_* variables are needed in this file, even though the module's registry namespace still says okta.

Key Changes:

  • Module source app.terraform.io/SAIFCorp/saif-nproles/okta → tf.pulumi.com/saif-corp/np-roles/okta, version >=1.0.0, <2.0.0 → >= 3.7.0, < 4.0.0
  • cloud block now targets tf.pulumi.com / saif-corp with no workspaces block
  • Removed the Okta provider block and okta_* variables — the module no longer requires them
  • YAML keys remain PascalCase: local.yaml.Username, local.yaml.Roles
  • Module parameters remain PascalCase: Username, Roles
  • Local variable names use snake_case: local.username, local.roles

  • Update infra/np-role-assignment-corp/my-roles.yml

â„šī¸ No changes required - The YAML file structure remains the same. Only the module version needs updating in the .tf file.

Username: your.name@saif.com
Roles:
  - role_name_1
  - role_name_2

External Test Users Updates

  • Update infra/test-user-maint-external/okta/external-test-users.generated.tf

Key Changes

Before After
local.user_map_yaml = yamldecode(...).UserMap local.user_map_yaml = yamldecode(...).user_map
module "saif-externaltestusers" source app.terraform.io/SAIFCorp/saif-externaltestusers/okta version >= 1.0.0, < 2.0.0 module "external-test-users" source tf.pulumi.com/saif-corp/external-test-users/okta version >= 3.7.0, < 4.0.0
Module parameter UserMap user_map
Module parameter PasswordMap password_map

Full Updated File:

terraform {
  cloud {
    hostname     = "tf.pulumi.com"
    organization = "saif-corp"
  }

  required_providers {
    okta = {
      source = "okta/okta"
    }
  }
}

provider "okta" {}

variable "password_map" {
  description = "The map of user passwords"
  type        = map(string)
  sensitive   = true
}

locals {
  user_map_yaml = yamldecode(file("./my-test-users.yml")).user_map
  user_map      = { for value in local.user_map_yaml : value.login => value }
}

module "external-test-users" {
  source       = "tf.pulumi.com/saif-corp/external-test-users/okta"
  version      = ">= 3.7.0, < 4.0.0"
  user_map     = local.user_map
  password_map = var.password_map
}
  • Update infra/test-user-maint-external/okta/my-test-users.yml

Before

UserMap:
  - login: testuser1@example.com
    first_name: Test
    last_name: User1
    email: testuser1@example.com

After

user_map:
  - login: testuser1@example.com
    first_name: Test
    last_name: User1
    email: testuser1@example.com

Key Changes:

  • UserMap → user_map

3ī¸âƒŖ Remove Bootstrap Configuration

The bootstrap workspaces only existed to create HCP Terraform workspaces. The orchestrator creates the stacks on Pulumi Cloud, so the bootstrap root is deleted, not migrated.

  • Delete infra/test-user-maint-external/bootstrap/ (including bootstrap.generated.tf)

4ī¸âƒŖ Pipeline Updates

Update Azure DevOps pipelines to reference Forge 3.0 templates.

Non-Prod Roles Pipeline

  • Update .azdo/np-roles-pipeline.yml

Before

resources:
  repositories:
    - repository: templates
      type: git
      name: SAIF/pipeline-templates

extends:
  template: okta-terraform-np-roles-user.yml@templates
  parameters:
    ProjectId: $(ProjectId)

After

resources:
  repositories:
    - repository: templates
      type: git
      name: SAIF/pipeline-templates
      ref: refs/heads/releases/v3

extends:
  template: test-tools-np-roles.yml@templates
  parameters:
    projectId: ${{ variables.ProjectId }}

Key Changes:

  • Add ref: refs/heads/releases/v3 to the template repository reference
  • Extend test-tools-np-roles.yml (v2 orchestrator, Pulumi Cloud backend) instead of okta-terraform-np-roles-user.yml
  • The stack is {project_id}_np-role-assignment

External Test Users Pipeline

  • Update .azdo/external-test-users-pipeline.yml

Before

resources:
  repositories:
    - repository: templates
      type: git
      name: SAIF/pipeline-templates

extends:
  template: okta-terraform-external-test-users.yml@templates
  parameters:
    CreateUser: ${{variables.Username}}
    DeployType: 'apply'

After

resources:
  repositories:
    - repository: templates
      type: git
      name: SAIF/pipeline-templates
      ref: refs/heads/releases/v3

variables:
  - template: vars.yml
  - template: saif-vars.yml@templates

extends:
  template: test-tools-external-test-users.yml@templates
  parameters:
    projectId: ${{ variables.ProjectId }}
    username: ${{ variables.Username }}

Key Changes:

  • Add ref: refs/heads/releases/v3 to the template repository reference
  • Extend test-tools-external-test-users.yml instead of okta-terraform-external-test-users.yml
  • Remove the TerraformCloud and {username}-ext-test-users-password-map variable groups from variables:. The orchestrator loads the password map group itself from the username parameter (secrets.variableGroupName)
  • The stack is {project_id}_ext-test-users. Okta credentials come from the saif-corp/saif/test Pulumi ESC environment as OKTA_* environment variables

Token Generation Pipeline (Optional)

If your test-tools repository includes a token generation pipeline:

  • Update .azdo/gen-token-pipeline.yml

Before

resources:
  repositories:
    - repository: templates
      type: git
      name: SAIF/pipeline-templates

extends:
  template: okta-terraform-gen-token.yml@templates

After

resources:
  repositories:
    - repository: templates
      type: git
      name: SAIF/pipeline-templates
      ref: refs/heads/releases/v3

extends:
  template: okta-terraform-gen-token.yml@templates

5ī¸âƒŖ Validation

After completing all changes, validate your configuration:

  • Check Terraform formatting
# Format all Terraform files
terraform -chdir=./infra/np-role-assignment-corp fmt
terraform -chdir=./infra/test-user-maint-external/okta fmt
  • Validate YAML syntax
# Check YAML files are valid
Get-Content ./infra/np-role-assignment-corp/my-roles.yml | ConvertFrom-Yaml
Get-Content ./infra/test-user-maint-external/okta/my-test-users.yml | ConvertFrom-Yaml
  • Review pipeline changes
# Search for any remaining references to old template refs
Get-ChildItem -Path .azdo -Filter *.yml | Select-String "repository: templates" -Context 0,3

🔍 Common Casing Patterns

YAML File Keys

Non-Prod Role Assignment (no changes):

Key Casing
Username PascalCase
Roles PascalCase

External Test Users (snake_case):

Before (PascalCase) After (snake_case)
UserMap user_map

Module Input Parameters

Okta modules (PascalCase - no changes):

Module Parameter Casing
Username PascalCase
Roles PascalCase
user_map snake_case
password_map snake_case

Module Versions

All Terraform modules must be updated to version 3.x:

Before After
saif-nproles/okta >=1.0.0, <2.0.0 tf.pulumi.com/saif-corp/np-roles/okta >= 3.7.0, < 4.0.0
saif-externaltestusers/okta >=1.0.0, <2.0.0 tf.pulumi.com/saif-corp/external-test-users/okta >= 3.7.0, < 4.0.0
bootstrap-exttestusers/saif >= 1.0.0, < 2.0.0 Removed (delete the bootstrap root)

📚 Resources


🤖 Using an AI Agent for Migration

Use GitHub Copilot to automate this migration. Copy and paste the following prompt:

Complete the Forge v2 to v3 migration for this test-tools repository following the migration guide.

First, use `get_doc` to retrieve the full migration guide: `learn/migration/test-tools-v2-to-v3`
Then copy it to `docs/migration/test-tools-v2-to-v3.md` in the repo so you can track progress.

Use the `#todo` tool to create a todo list with these tasks:

**Migration Sections (from the guide):**
1. Verify Folder Structure - Confirm np-role-assignment-corp/ exists (rename if needed)
2. Module Version Updates - Update module versions to 3.0, update external test users YAML to snake_case
3. Bootstrap Configuration - Delete the bootstrap root if it exists
4. Pipeline Updates - Update to v3 pipeline templates with refs/heads/releases/v3 reference
5. Validation - Format Terraform files, validate YAML syntax, review pipeline changes

After completing each section:
1. Validate the Terraform syntax using `terraform fmt`
2. Update the local migration progress file at `docs/migration/test-tools-v2-to-v3.md` with completed checkboxes
3. Mark the todo as complete using `#todo` before moving to the next section

**Delegation Strategy:**
Use the `#runSubagent` tool to efficiently discover files before making changes. Launch subagents in parallel for discovery tasks:

- **For Folder Structure (Task 1):** Verify np-role-assignment-corp/ exists (rename if needed)
- **For Module Updates (Task 2):** Find module version constraints in .tf files and UserMap in external test users YAML
- **For Pipeline Updates (Task 4):** Find all .yml files in .azdo/ that reference pipeline templates

Each subagent should return the complete list of file paths that need updating for its assigned task.

💡 Tip: The agent will create a todo list to track progress, run terminal commands, delegate complex searches to sub-agents, and can even submit improvements to this guide based on issues encountered during your migration.