Skip to content

Can't import github_branch_protection using repository node_id:branch pattern #671

Closed

Description

@faultylee

Terraform Version

  • v0.14.3
  • terraform-provider-github_v4.2.0

Affected Resource(s)

  • branch_protection

Debug Output

I had to masked the org
https://gist.github.com/faultylee/0fa1a34cade6ee047f9e81967fd93993

Expected Behavior

Import of branch_protection works with node_id

Actual Behavior

node_id use during import was interpreted as repo_name

Steps to Reproduce

  • terraform init
  • terraform import github_branch_protection.repo_branch_protection 'MDEwOlJlcG9zaXRvcnkzMzI2ODM4OTc=:main'

References

Activity

  1. added
    Type: Bug
    Good first issue
    on Jan 26, 2021
  2. added a commit that references this issue on Feb 28, 2021
  3. tibbes commented on Mar 1, 2021

    @tibbes
    Contributor

    Thanks for the bug report @faultylee. The fix has been merged, so it will be in the next release.

  4. bateller commented on Mar 8, 2021

    @bateller

    Thanks for the bug report @faultylee. The fix has been merged, so it will be in the next release.

    @tibbes Are we sure this is resolved? I'm still having issues importing with node_id

    Initializing the backend...
    
    Initializing provider plugins...
    - Finding integrations/github versions matching "~> 4.0"...
    - Installing integrations/github v4.5.1...
    - Installed integrations/github v4.5.1 (signed by a HashiCorp partner, key ID 38027F80D7FD5FB2)
    
    $ terraform import github_branch_protection.some_repo 'MDEwOlJlcG9zaXRvcnkxMTE1NjgzNTQ=:master'
    github_branch_protection.some_repo: Importing from ID "MDEwOlJlcG9zaXRvcnkxMTE1NjgzNTQ=:master"...
    
    Error: nil entry in ImportState results. This is always a bug with
    the resource that is being imported. Please report this as
    a bug to Terraform.
    
  5. tibbes commented on Mar 8, 2021

    @tibbes
    Contributor

    @bateller, it looks like there is some missing error checking. Apologies.

    I can reproduce that message, but only when the branch protection rule does not exist. I will open a pull request to fix that. Please can you verify that the master branch is actually protected on that repository?

  6. bateller commented on Mar 8, 2021

    @bateller

    @tibbes Yes, I can confirm master didn't have branch protection.

    Sorry about that (I didn't have Admin permission on the repo I was importing)

    Tried on another repo within the same org (and with the same Terraform setup) with a repo I had Admin access on and imported branch protection for master successfully.

    It appears this issue (and #597) are failing for me due to not checking if the imported resource exists on Github (which would be a nice check for those of us using Terraform to manage Github when we don't have direct Admin access)

  7. tibbes commented on Mar 8, 2021

    @tibbes
    Contributor

    I've opened #721 to fix the error message. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueType: Bugr/branch_protection

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions