You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need instructions for migrating from hashicorp/github to integrations/github #652
Now that GitHub has taken over ownership of the github provider we need some instructions for upgrading.
I tried the obvious:
update required_providers:
change source attribute to integrations/github.
change version to 4.2.0 (from 4.1.0 in my case)
terraform state replace-provider registry.terraform.io/hashicorp/github registry.terraform.io/integrations/github
terraform init
This shows it installing both hashicorp 4.1.0 and integrations 4.2.0
terraform plan
Unfortunately, it then seems to hang forever.
TRACE shows that it is trying to access github.com (it should be using our enterprise server) without specifying the org using the hashicorp 4.1.0 provider:
[DEBUG] plugin.terraform-provider-github_v4.1.0_x4: GET /orgs//teams/sre-team HTTP/1.1
[DEBUG] plugin.terraform-provider-github_v4.1.0_x4: Host: api.github.com
There is exactly oneGET using the 4.2 provider:
[DEBUG] plugin.terraform-provider-github_v4.2.0: GET /api/v3/orgs/the-org-on-our-ghe HTTP/1.1
[DEBUG] plugin.terraform-provider-github_v4.2.0: Host: github.example.com
No matter what I do, terraform insists on using the official hashicorp provider.
Reacted by Brandon Hartshorn, Christian Höltje, Latifa TAKFAOUI, Adeel Ahmad, Kevin Behrens, Aleksandar Licul, Onur Gokkocabas, Thiago Fortunato, s-okayama, Brian A. Teller and 10 more
terraform state replace-provider kensu.io/kensu/github integrations/github
terraform init
terraform plan
And it works; at the beginning I didn't update my modules so I got some confusion....
(kensu.io/kensu/github is fork of hashicorp/github with last features suggested on the repo)
Reacted by Jeremy Udit, Lars Tobias Skjong-Børsting, daniel, John Bedalov and Erwan Ben Souiden
🤔 maybe we document this as a breaking change?
I can get the CHANGELOG updated if it helps boost visibility of the state replace-provider procedure above.
Reacted by Francois BAYART, Martin Coll, Adeel Ahmad, Arvid Widerberg, Aidan Feldman, Cole Bittel, John Bedalov and Erwan Ben Souiden
@docwhat I am also seeing the same issue as you do and it seems that, at least for me, it was due to the bug described here: #655 (comment)
where both values for organization and token in provider block were ignored.
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Warning: Additional provider information from registry
The remote registry returned warnings for
registry.terraform.io/hashicorp/github:
For users on Terraform 0.13 or greater, this provider has moved to
integrations/github. Please update your source in required_providers.
@MRostanski it looks like you're hitting the same thing we just did: if you use modules, each module needs to declare its own required_providers block with the source of the github module pointing to integrations/github instead of hashicorp/github.
Without that, you end up with the mix of the two providers...
Reacted by Manuel, Brian A. Teller, Raj Saxena, Ben Abrams, Alexandru Ungur, manuel-cc, Antoine Méausoone, Jon Frisby, Guillaume O, Jobim Robinsantos and 8 more
Reacted by Brandon Hartshorn, Raj Saxena, Alexandru Ungur and Aidan Feldman
The workaround is to put this snippet with the main.tf and also inside the github module directory. terraform { required_providers { github = { source = "integrations/github" version = "4.13.0" } } }
lets assume we have main.tf and subdirectory containing github.tf. The main file uses a module that uses the github resource. Now the problem begins. Terraform download both integrations/github and hashicorp/github, but if you put the required_providers in both places, with the main and within the subdirectory, it stops the problem.
Hope I was clear.
this results in terraform providers command to output only
:
This should prevent terraform to download hashicorp/github provider.
Note that you also need to replace the provider in remote state file using terraform state replace-provider
@rmc47: @MRostanski it looks like you're hitting the same thing we just did: if you use modules, each module needs to declare its own required_providers block with the source of the github module pointing to integrations/github instead of hashicorp/github. Without that, you end up with the mix of the two providers...
I have already run terraform state replace-provider -- registry.terraform.io/hashicorp/github registry.terraform.io/integrations/github so there are no references to hashicorp/github in the state.
When using github resource inside modules, then this becomes quite confusing. As an experiment, I put nothing github under required_providers in the top level, nor inside the modules. When I then run terraform init, it wil pick a mix of hashicorp/github and integrations/github, but both with the same version (v4.28.0). In addition it prints a message from the Registry:
Warning: Additional provider information from registry
The remote registry returned warnings for registry.terraform.io/hashicorp/github:
For users on Terraform 0.13 or greater, this provider has moved to integrations/github. Please update your source in required_providers.
Now, if I put integrations/github in required_providers in the top level terraform only, and nothing in the modules, then it still downloads a mix of the two provider names, and prints the above warning from the registry.
It initialized successfully, but the provider config in the top level isn't inherited to the module, so it can't work.
Then, if I integrations/github and provider config only into the modules and not in the top level, then it only downloads integrations/github and there is no mention of hashicorp/github. It initialized successfully and the provider config is correctly set.
So, I guess this problem is caused by both hashicorp/github and integrations/github using the same name github, and that if I specify no provider, it will by default pick hashicorp/github and in addition integrations/github if it's referenced in the state file. If it would always go for integrations/github instead, then maybe the whole problem goes away?
So, I guess this problem is caused by both hashicorp/github and integrations/github using the same name github, and that if I specify no provider, it will by default pick hashicorp/github and in addition integrations/github if it's referenced in the state file.
Can this be considered a bug, then, and not just about documentation?
I'm not sure how I would go about troubleshooting that at the provider level. I wonder if that's something specific to the Terraform platform or tooling.
b. rm -rf .terraform .terraform.lock.hcl
c. terraform init
it still install hashicorp/github by default.
try to relpace state
terraform state replace-provider registry.terraform.io/hashicorp/github registry.terraform.io/integrations/github
and run step b and c. but getting same result.
finally, I add following block in local tf. and run step b and c.
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
Activity
frbayart commentedon Jan 8, 2021
On my side I make:
And it works; at the beginning I didn't update my modules so I got some confusion....
(kensu.io/kensu/github is fork of hashicorp/github with last features suggested on the repo)
jcudit commentedon Jan 9, 2021
🤔 maybe we document this as a breaking change?
I can get the CHANGELOG updated if it helps boost visibility of the
state replace-providerprocedure above.frbayart commentedon Jan 9, 2021
Also @docwhat if the problem persists, it's probably useful to check
terraform providersYou have details per plan and modules, output is like:
aliculPix4D commentedon Jan 20, 2021
@docwhat I am also seeing the same issue as you do and it seems that, at least for me, it was due to the bug described here: #655 (comment)
where both values for organization and token in provider block were ignored.
by setting the
GITHUB_TOKEN,GITHUB_ORGANIZATIONenvironmental variables, the upgrade was successful and onlyintegrations/github(4.3.0) can be used.jcudit commentedon Feb 3, 2021
Adding the
required_providersconfiguration block may unblock others experiencing this.MRostanski commentedon Feb 20, 2021
@jcudit no, unfortunately it does not. I have:
and still both get installed:
Initializing provider plugins...
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Warning: Additional provider information from registry
The remote registry returned warnings for
registry.terraform.io/hashicorp/github:
integrations/github. Please update your source in required_providers.
What is going on in
terraform providers:rmc47 commentedon Feb 25, 2021
@MRostanski it looks like you're hitting the same thing we just did: if you use modules, each module needs to declare its own
required_providersblock with the source of the github module pointing tointegrations/githubinstead ofhashicorp/github.Without that, you end up with the mix of the two providers...
ops-hummus commentedon Aug 19, 2021
The workaround is to put this snippet with the main.tf and also inside the github module directory.
terraform { required_providers { github = { source = "integrations/github" version = "4.13.0" } } }lets assume we have main.tf and subdirectory containing github.tf. The main file uses a module that uses the github resource. Now the problem begins. Terraform download both integrations/github and hashicorp/github, but if you put the required_providers in both places, with the main and within the subdirectory, it stops the problem.
Hope I was clear.
aliculPix4D commentedon Aug 23, 2021
Another simplification that worked for me is to move the following section from
main.tfto i.etf-modules/github/main.tfand just send the token to the module as a variable:
this results in

terraform providerscommand to output only:
This should prevent terraform to download
hashicorp/githubprovider.Note that you also need to replace the provider in remote state file using
terraform state replace-providerTheJackson commentedon May 26, 2022
This is the one, thanks for this workaround!
larstobi commentedon Aug 2, 2022
I have already run
terraform state replace-provider -- registry.terraform.io/hashicorp/github registry.terraform.io/integrations/githubso there are no references to hashicorp/github in the state.When using github resource inside modules, then this becomes quite confusing. As an experiment, I put nothing github under
required_providersin the top level, nor inside the modules. When I then runterraform init, it wil pick a mix ofhashicorp/githubandintegrations/github, but both with the same version (v4.28.0). In addition it prints a message from the Registry:Now, if I put
integrations/githubinrequired_providersin the top level terraform only, and nothing in the modules, then it still downloads a mix of the two provider names, and prints the above warning from the registry.It initialized successfully, but the provider config in the top level isn't inherited to the module, so it can't work.
Then, if I
integrations/githuband provider config only into the modules and not in the top level, then it only downloadsintegrations/githuband there is no mention ofhashicorp/github. It initialized successfully and the provider config is correctly set.So, I guess this problem is caused by both
hashicorp/githubandintegrations/githubusing the same namegithub, and that if I specify no provider, it will by default pickhashicorp/githuband in additionintegrations/githubif it's referenced in the state file. If it would always go forintegrations/githubinstead, then maybe the whole problem goes away?ahmadnassri commentedon Aug 23, 2022
I can confirm @larstobi findings on my end.
usmonster commentedon Nov 29, 2022
Can this be considered a bug, then, and not just about documentation?
kfcampbell commentedon Nov 30, 2022
I'm not sure how I would go about troubleshooting that at the provider level. I wonder if that's something specific to the Terraform platform or tooling.
jackyou84 commentedon Mar 12, 2023
I meet same issue lately.
I try to following steps:
a. change providers from module
in local just refer providers:
b. rm -rf .terraform .terraform.lock.hcl
c. terraform init
it still install hashicorp/github by default.
try to relpace state
terraform state replace-provider registry.terraform.io/hashicorp/github registry.terraform.io/integrations/github
and run step b and c. but getting same result.
finally, I add following block in local tf. and run step b and c.
and only integrations/github is used. and tf plan also smoothly.
jackyou84 commentedon Mar 12, 2023
so seems to switch providers from old one. we must update both module and local tf provider.
mado-m commentedon Sep 15, 2023
I have also solved this problem by using replace-provider.
github-actions commentedon Jun 12, 2024
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!larstobi commentedon Jun 19, 2024
This doesn't in fact solve the issue completely. See my above findings.