Problem
After you make changes to a VCS connection, such as re-authorizing it, webhooks may show 401 Unauthorized errors on the VCS provider side.
In the webhook details, the following error message appears.
{
"errors": [
"vcs repo no longer connected to a workspace"
],
"success": false
}This error is also visible in the tfe-sidekiq log file from a Terraform Enterprise support bundle.
[ERROR] resource=Vcs::WebhookPayloadProcessorWorker msg=Received error parsing the webhook_payload exception=401 Unauthorized webhook_payload_id=59885 service_provider=bitbucket_hosted vcs_repo_external_id=vcrepo-Ua6bKLzxkmppmmML metadata={"request_id"=>"3008623a-24bd-4098-a3a3-4940deaf5a8a"} jid=1acc5328bfa9e6b77868da0dCause
When you modify a VCS connection, the existing webhooks for all modules associated with the old VCS connection become invalid.
Solutions
To resolve this issue, you must delete the module and then re-publish it to your organization. The publishing process also imports all previous valid tags or versions of that module.
Solution 1: Use the Terraform Enterprise UI
- Delete the module from the private registry.
- Publish the module again to re-establish the connection.
Solution 2: Use the API
- List all modules for the organization to get a list of your modules.
- Run the Get a Module API endpoint for each module and parse the response to identify modules without a Webhook URL.
-
For each module that does not have a Webhook URL, export the
vcs-repoobject from the API response. It will look similar to the following example."vcs-repo": { "branch": "", "ingress-submodules": true, "identifier": "lafentres/terraform-aws-my-module", "display-identifier": "lafentres/terraform-aws-my-module", "oauth-token-id": "ot-hmAyP66qk2AMVdbJ" } - Delete the module using the API.
-
Publish the module again using the
vcs-repoinformation from step 3 in the payload.
Outcome
After you complete these steps, Terraform Enterprise re-registers the webhook, and you can publish new releases to your modules.