Module Artifacts
Understand how Harness IaCM packages module versions as artifacts, how workspace executions use them without Git credentials, and how to keep versions in sync.
When you register a module and the onboarding pipeline runs for the first time, Harness packages each tagged version of your module as a ZIP artifact and stores it on the IaCM server. Workspace executions that reference your module fetch the artifact directly. No Git credentials are needed at runtime.
This page explains what gets stored, how workspace executions use artifacts, how to keep versions current with auto-sync and manual sync, and how to migrate existing modules that were registered before artifact storage was available.
What gets stored
Each time the onboarding pipeline runs, it processes every Git tag that matches your configured tag pattern and stores the following per version:
Metadata: Inputs, outputs, dependencies, resources, and submodule information parsed from your module's files.
README: The contents of your
README.md, rendered on the Readme tab.ZIP artifact: A compressed archive of the repository at that tag, stored in object storage. This is what workspace executions download at runtime.
The onboarding pipeline runs in the plugins/harness_terraform container image, the same image used by other IaCM steps. It clones the repository, reads all matching tags, and publishes the results to the IaCM server.
How workspace executions use artifacts
When a workspace runs a pipeline that references an artifact-stored module, Harness:
Looks up the requested module version in the registry.
Fetches the ZIP artifact from object storage.
Passes the unpacked archive to the plugin, which uses it as the module source.
Because the ZIP is served from Harness-managed storage, no Git credentials are needed at workspace runtime. The onboarding pipeline handles all Git access at onboard time.
This resolves the credential management problem from the original Git reference flow, where Harness injected Git credentials from every module in the account into every workspace execution.
Sync module versions
Versions appear in the registry only after the onboarding pipeline runs. Two mechanisms keep the version list current.
Auto-sync
When you enable auto-sync during registration, Harness creates a webhook trigger on the onboarding pipeline. Whenever a new Git tag that matches your tag pattern is pushed to the module repository, the trigger fires and the new version is available in the registry automatically, with no manual action required.
Go to Register a Module to configure auto-sync during the registration wizard. You can also enable or disable it from the module detail page after registration.
Manual sync
If auto-sync is disabled, or if a sync fails and you need to re-run it, select the Sync button on the module detail page. This triggers the onboarding pipeline on demand and picks up any new tags since the last run.
Troubleshooting
Migrate existing modules to artifact storage
If you have modules that were registered before artifact storage was available (using the Git reference flow), use the migrate-onboarding-pipeline.sh script to bulk-assign an onboarding pipeline to them. Once the pipeline runs, those modules transition to artifact storage.
VALIDATE IN THE UI FIRST
Before running this script, manually onboard one module through the Harness UI. Register a test module, configure its onboarding pipeline (choosing the Org and Project), and verify the pipeline execution completes successfully. This confirms the pipeline is correctly set up and gives you the correct Org and Project values for the script.
Prerequisites
bash (macOS or Linux), curl, and jq installed (
brew install jqon macOS).Harness API key (Personal Access Token) with module registry edit permissions.
Account ID for the target Harness account.
Org and Project where the onboarding pipeline lives or will be created.
Script options
--base-url
Yes
Base URL of the IaCM server (for example, https://app.harness.io/gateway/iacm).
--api-key
Yes
Harness Personal Access Token (PAT).
--account
Yes
Harness account identifier.
--pipeline-org
Yes
Org where the onboarding pipeline lives.
--pipeline-project
Yes
Project where the onboarding pipeline lives.
--pipeline-id
No
Pipeline identifier. Defaults to iacm_auto_generated_onboarding_pipeline.
--autosync
No
Enable auto-sync (true or false). Default: true.
--all
One of --all or --module-ids required
Target all modules without an onboarding pipeline.
--module-ids
One of --all or --module-ids required
Comma-separated list of specific module IDs to update (for example, 12,34,56).
--limit
No
Max number of modules to update (only applies with --all).
--dry-run
No
Preview which modules would be updated without making changes.
Run the migration
Follow the steps below in order. Do not skip the dry run or verification steps.
Step 1: Preview changes with a dry run
Always start with a dry run to see which modules the script would update:
Review the listed modules and total count.
Step 2: Start with a small batch
Do not migrate all modules at once. Start with 5 to 10 modules to verify everything works:
Step 3: Verify pipeline executions
After each batch, verify the onboarding pipeline executions before proceeding:
In the Harness UI, navigate to Pipelines, then select Executions in the Org and Project where the onboarding pipeline lives.
Confirm that the onboarding pipeline was triggered for each updated module.
Verify every execution completed successfully (green status on all stages).
Spot-check a few modules in the Module Registry to confirm versions synced and artifacts were stored.
DO NOT PROCEED UNTIL VERIFIED
Do not run the next batch until all executions from the current batch succeed. If any executions fail, investigate the cause before continuing. Retry failed modules individually using --module-ids.
Step 4: Increase batch size
Once you are confident the migration is working, increase the batch size gradually (for example, 5, then 25, then 50, then 100). Continue verifying pipeline executions after each run. The script automatically skips modules that already have an onboarding pipeline assigned, so re-running with --all is safe.
Step 5: Migrate all remaining modules
When you are confident everything is working, run without --limit to migrate all remaining modules, then check all pipeline executions one final time.
What the script does
For each module being updated, the script:
Fetches modules from the account by specific IDs (
--module-ids) or all modules (--all).Filters modules that do not have an existing onboarding pipeline (when using
--all). The--limitoption caps the number processed.Ensures the onboarding pipeline exists by calling the create endpoint (a no-op if the pipeline already exists).
Updates each module with the pipeline identifier, org, project, and auto-sync flag.
Reports success and failure counts and lists any failed modules.
Migration troubleshooting
HTTP 401 error
Verify your --api-key and --account values are not swapped. The account is the short ID; the API key is the long PAT token.
HTTP 403 error
Ensure your API key has module registry edit permissions.
Module ID not found
Double-check the module ID exists in the account. Use --dry-run with --all to list available modules.
Pipeline creation fails
Verify the Org and Project exist and that you have pipeline creation permissions in them.
Some modules fail to update
Check the error message in the output. Re-run the script with the failed --module-ids to retry.
Auto-sync does not trigger after migration
Confirm the webhook trigger was created on the onboarding pipeline. Navigate to the pipeline's Triggers tab and verify the trigger is active.
Safety notes
--dry-runfirst. Always preview before making changes.Small batches. Catch issues early before they affect many modules.
Verify after every run. Check the Harness UI to confirm all executions succeeded before the next batch.
Re-running is safe. The script skips already-onboarded modules when using
--all.Existing data is preserved. The script only adds onboarding pipeline fields; all other module properties remain unchanged.
Connector scope: If your modules use a Git connector scoped to a specific Org and Project, the onboarding pipeline must be in that same Org and Project, so
--pipeline-organd--pipeline-projectmust match the connector scope.
Next steps
Go to Explore Module Details to review the parsed metadata tabs that the onboarding pipeline populates.
Go to Use a Module to reference an artifact-stored module from your OpenTofu or Terraform configuration.
Go to Test a Module to set up automated testing for new versions.
Last updated
Was this helpful?