Closed MPV closed 1 year ago
@MPV Thank you for reporting the issue.
As you reported in the upstream, the root cause of this problem is that the terraform-provider-github repo doesn't have the latest release.
As a workaround, we recently added --source-type tfregistryProvider
as an experimental feature in v0.4.2, so you can now get the latest version from Terraform Registry:
$ tfupdate release latest --source-type tfregistryProvider hashicorp/github
3.0.0
Note that it's experimental and unstable because we are currently depending on an undocumented API.
Sounds like their next version (3.1.1) will start supporting this, as per https://github.com/terraform-providers/terraform-provider-github/issues/563#issuecomment-711093843
@minamijoyo I see that your suggestion --source-type tfregistryProvider
works on the tfupdate release latest
command, I don't see any such options for the tfupdate provider
command (which actually does the upgrade):
$ tfupdate provider --help
Usage: tfupdate provider [options] <PROVIDER_NAME> <PATH>
Arguments
PROVIDER_NAME A name of provider (e.g. aws, google, azurerm)
PATH A path of file or directory to update
Options:
-v --version A new version constraint (default: latest)
If the version is omitted, the latest version is automatically checked and set.
Getting the latest version automatically is supported only for official providers.
If you have an unofficial provider, use release latest command.
-r --recursive Check a directory recursively (default: false)
-i --ignore-path A regular expression for path to ignore
If you want to ignore multiple directories, set the flag multiple times.
This is using version 0.4.2:
$ tfupdate --version
0.4.2
Here are some examples of how this doesn't work when providers aren't available under the terraform-providers
GitHub organization:
$ tfupdate provider openstack .
failed to get the latest release for terraform-providers/terraform-provider-openstack: GET https://api.github.com/repositories/294770956/releases/latest: 404 Not Found []
vs
$ tfupdate release latest terraform-provider-openstack/terraform-provider-openstack
1.35.0
$ tfupdate release latest --source-type tfregistryProvider terraform-provider-openstack/openstack
1.35.0
$ tfupdate provider sops .
failed to get the latest release for terraform-providers/terraform-provider-sops: GET https://api.github.com/repos/terraform-providers/terraform-provider-sops/releases/latest: 404 Not Found []
vs
$ tfupdate release latest carlpett/terraform-provider-sops
0.5.3
$ tfupdate release latest --source-type tfregistryProvider carlpett/sops
0.5.3
@MPV The current implementation of the tfupdate provider
command implicitly assumes the official providers are hosted on terraform-providers/
GitHub organization. It was ok a few months ago. However some providers were recently moved to other organizations. It seems that the maintenance policy was changed, but I cannot find any official announcement from HashiCorp. Anyway, the original assumption is not true now. I think we should detect the source location from configurations.
https://github.com/integrations/terraform-provider-github/issues/563 has been resolved now, but I still don't get tfupdate
to work for GitHub.
For example, having a provider.tf
file that looks like this:
terraform {
required_version = "1.0.9"
required_providers {
google = {
version = "3.85.0"
}
github = {
version = "4.11.0"
}
}
}
Upgrading google
works, but not github
— any suggestions?
$ tfupdate provider google .
$ git diff | cat
diff --git a/umbrellas/pagero-ozone/provider.tf b/umbrellas/pagero-ozone/provider.tf
index df37fb9..b7e2a9d 100644
--- a/umbrellas/pagero-ozone/provider.tf
+++ b/umbrellas/pagero-ozone/provider.tf
@@ -2,7 +2,7 @@ terraform {
required_version = "1.0.9"
required_providers {
google = {
- version = "3.80.0"
+ version = "3.88.0"
}
github = {
version = "~> 4.17.0"
vs
$ tfupdate provider github .
no releases found
$ echo $?
1
Any ideas?
I don't know why, but from my observation, the transfer method of org seems to be different.
terraform-providers/terraform-provider-google
redirects to hashicorp/terraform-provider-google
.
terraform-providers/terraform-provider-github
also redirects to hashicorp/terraform-provider-github
.
However, hashicorp/terraform-provider-github
is a fork of integrations/terraform-provider-github
and it doesn't redirect to integrations
org in GitHub API call.
As a workaround, you can get the latest version first using release latest
command and then update provider with the version explicitly.
$ VERSION=$(tfupdate release latest integrations/terraform-provider-github)
$ echo $VERSION
4.17.0
$ tfupdate provider -v $VERSION github .
I'm going to close this because there has been no activity on this recently. Please feel free to reopen this if you have any questions or suggestions. Thanks!
This works:
Get latest version of
terraform-provider-vault
:But this doesn't:
Get latest version of
terraform-provider-github
Notes
I've also raised an issue over at https://github.com/terraform-providers/terraform-provider-github/issues/563