-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform-import failure: Cannot import non-existent remote object #647
Comments
➕ |
Same in Terraform v0.14.8 and terraform-provider-github v4.5.2. |
The name of the organization is empty in the log.
|
|
Your debug output has the following snippet:
in which we see My guess is that somewhere we're accidentally appending an extra slash, and if we removed that, the GET request would succeed. I'm going to poke around the code a little bit to see if I can prove that. |
Nope, you're totally correct that it's indicative of a missing owner. I've been unable to reproduce this locally, which makes me think it's perhaps related to the |
I've been unable to repro this using Terraform Cloud, either...my full HCL is below:
The only things I've attempted to change from your setup is my GitHub organization name, and my Terraform Cloud organization name. I've also copied in your In order to run this test, I created a
@lens0021 is there anything about this reproduction that appears incorrect or not in line with what you're doing? |
@kfcampbell Thank you for your investigation. I retried the import in few other ways, I have noticed it was
It will be helpful if there could be a message for the missing token, Thanks! |
Oh I'm glad to hear you got it resolved! I think a 404 is somewhat appropriate if a token isn't present, since visiting a GitHub private repository from an unauthenticated or anonymous account will give a 404. I agree it's confusing to see the path missing the organization and perhaps the messaging could be improved. |
still not resolved for me. |
So for anyone having this issue. |
I've also been experiencing this issue, specifically when trying to import a If I run |
I had the same symptom. Like @lens0021 , I saw in the debug output that the GET request to GitHub was missing the organization name part:
And just as he did, setting What I'd love to see is the error message improvement. |
The original code and comment mentions that we shouldn't change the logic for how the configuration sets the owner without creating a new major release as it'd break backwards compatibility. In the meantime, I've created this PR as a starting point to log which organization/owner is selected and therefore hopefully make it easier to see how the configuration is being interpreted. Do the folks on this thread see value/benefit in this? Feedback is appreciated. |
IMHO the true cause of this is here: terraform-provider-github/github/config.go Lines 146 to 152 in 5a88727
When GITHUB_TOKEN env variable is not set (c.Anonymous() is true), the Owner.name property is not set. Owner is |
Oooh, good point. That is awfully confusing...in the absence of a total handling rewrite, I've added a few more logs in the PR that produce output such as: (in an environment with both token and owner set)
(in an environment in which the organization is set but the token is not)
(for a user with neither owner nor token set)
It's still confusing since we're setting the |
To sum up:
Proposal:
This leads into unfortunate resource
|
Looks like at least Click to expandterraform {
required_providers {
github = {
source = "integrations/github"
version = "~> 4.0"
}
}
}
variable "github_token" {
description = "A GitHub OAuth / Personal Access Token."
sensitive = true
type = string
}
provider "github" {
owner = "ACME"
token = var.github_token
} Add this is logged:
However, all works as expected when I use |
Setting |
integrations/github has a problem that ignores provider args. integrations/terraform-provider-github#647 It's expected to be fixed in the next major update at 5.0.
👋 Hey Friends, this issue has been automatically marked as |
I'm having the same issue with the latest version of this provider (5.18.3) and a repo internal to my org (myorg/mobile). I set
|
I am having the same issue now as well, on the same version as @crmne It seem to succeed ( It also refuses to work with a nested module, although the nested module is able to create repos from scratch.
|
I have now solved this problem. Several issues may have contributed.
god what a journey. Hope this helps and good luck. |
Thanks for your comments @coyotespike, glad that it worked for you but unfortunately they didn't help in my case. However, I managed to find the issue, by setting
the |
I managed to solve the issue for me. It looks like I didn't set |
I'm getting this error when using provider "github" {
owner = "tekumara"
app_auth {
}
} And setting the env vars:
With this authentication I can plan and apply, but not import. If I switch to |
Terraform Version
Terraform v0.14.3
provider "registry.terraform.io/hashicorp/github" { version = "4.1.0" }
Affected Resource(s)
Terraform Configuration Files
Full configuration: https://github.com/femiwiki/infra/blob/50eb0673787a8cab88041876632e45b6df6a2a57/github/repo.tf#L465-L472
Debug Output
https://gist.github.com/lens0021/35d5e8997a389bfcd91fa6cc976d2fbc
Expected Behavior
A state which is created based on https://github.com/femiwiki/legunto is Imported successfully.
Actual Behavior
"Error: Cannot import non-existent remote object" is printed. See the debug output for details.
Steps to Reproduce
terraform import github_repository.legunto legunto
Important Factoids
Our team is using Terraform Cloud (https://app.terraform.io/).
The text was updated successfully, but these errors were encountered: