Skip to content

Some resources can only be used in the context of an organization #501

Closed

Description

@emmahsax

Terraform Version

Terraform Version: 0.12.28
Provider Version: 2.9.0

Affected Resource(s)

  • github_branch
  • github_issue_label
  • probably others that I don't use as much

Terraform Configuration Files

resource "github_branch" "branch" {
  for_each      = toset(local.branches)
  repository    = github_repository.repo.name
  branch        = each.value
  source_branch = var.source_branch

  lifecycle {
    ignore_changes        = [branch, source_branch]
    create_before_destroy = true
  }
}

resource "github_issue_label" "label" {
  for_each   = var.labels
  repository = github_repository.repo.name
  name       = each.key
  color      = each.value
}

Debug Output

Setting debugging seems to yield any separate results from running w/out debugging.

Panic Output

No panic output.

Expected Behavior

Terraform should've had no problems creating GitHub branches and labels on repositories that are owned by a GitHub user.

Actual Behavior

Terraform erred with the following:

Error: This resource can only be used in the context of an organization, "foobar" is a user.

  on ../tf-library/label.tf line 1, in resource "github_issue_label" "label":
   1: resource "github_issue_label" "label" {

Error: This resource can only be used in the context of an organization, "foobar" is a user.

  on ../tf-library/branch.tf line 6, in resource "github_branch" "branch":
   6: resource "github_branch" "branch" {

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Use provider version 2.9.0 and specify a GitHub user as the owner
  2. Codify creating a new GH branch for a repository the GH user owns
  3. Codify creating a new label for a repository the GH user owns
  4. Run terraform init
  5. Run terraform apply
  6. See errors

Important Factoids

None that I can think of.

References

Activity

  1. anGie44 commented on Jun 29, 2020

    @anGie44
    Collaborator

    hi @emmasax4, thank you for creating this issue! as of v2.9.0 only the resources listed in the description of #465 , a subset of resources prefixed with repository, have support for individual user accounts as we decided to roll-out user level support in batches since this is a relatively large change in the provider. apologies the PR does not make it super clear! unfortunately this does not include branch and issue_label but with this issue we can keep track of areas still needing support :)

  2. emmahsax commented on Jun 29, 2020

    @emmahsax
    Author

    Ah okay sounds good. I will keep an eye out on future versions of the provider for branch and issue_label then!

  3. added
    Type: Feature
    on Jun 29, 2020
  4. added this to the v2.9.1 milestone on Jul 1, 2020
  5. jcudit commented on Jul 1, 2020

    @jcudit
    Contributor

    Aiming to tackle one or both of these resources in an upcoming release to mop up issues with v2.9.0. Thanks for raising this.

  6. sogaoh commented on Jul 1, 2020

    @sogaoh

    @anGie44 @jcudit
    From https://github.com/terraform-providers/terraform-provider-github/issues/422#issuecomment-652455877

    I couldn't create a github_actions_secret of individual Github repository similarly on v2.9.0.
    Could you please correspond in v2.9.1 ?

  7. emmahsax commented on Jul 16, 2020

    @emmahsax
    Author

    @anGie44 @jcudit According to this (https://github.com/terraform-providers/terraform-provider-github/blob/master/CHANGELOG.md#291-july-01-2020) it looks like the ability to use github_repository with user individual repos was reverted? And that those changes will be made in the next major release, along with, I'm assuming, the issues I brought up in this Issue?

    Is that an accurate assumption?

  8. modified the milestones: v2.9.1, v3.0.0 on Jul 21, 2020
  9. frezbo commented on Aug 8, 2020

    @frezbo

    This is really confusing with the revert that happened, I had to look at code changes and CHANGELOG to figure out why it was not working for personal repositories. For now I switched to provider version 2.9.0. Do we have a time line for the major release?

  10. jcudit commented on Aug 13, 2020

    @jcudit
    Contributor

    Apologies for the mixup there @frezbo, definitely confusing 🙃

    As for the next major release a couple of items are blocking:

    Given available bandwidth, my hope is that the release will ship sometime between September and October.

  11. dvargasfuertes commented on Aug 27, 2020

    @dvargasfuertes

    Is there anything blocking further review of that PR? anything I could do to help? Context is that I'm blocked from using github action secret resources with a non organization account

  12. jcudit commented on Sep 4, 2020

    @jcudit
    Contributor

    @dvargas92495 changes to unblock you (🤞) are now merged into the default branch. Any chance you can test this out?
    A new release will likely land mid next week.

  13. dvargasfuertes commented on Sep 4, 2020

    @dvargasfuertes

    I would love to test this out! Let me know when it's ready!

  14. dvargasfuertes commented on Sep 10, 2020

    @dvargasfuertes

    This appears to be working for me!

    provider "github" {
        owner = "dvargas92495"
    }
    
    resource "github_actions_secret" "deploy_aws_access_key" {
      repository       = "example-repo"
      secret_name      = "DEPLOY_AWS_ACCESS_KEY"
      plaintext_value  = "VALUE"
    }
  15. frezbo commented on Sep 11, 2020

    @frezbo

    yeh, this seems to be fixed in the 3.0.0 release.

  16. emmahsax commented on Sep 11, 2020

    @emmahsax
    Author

    According to this page, 3.0.0 isn't released yet?

  17. emmahsax commented on Sep 14, 2020

    @emmahsax
    Author

    Apparently github_branch_protection is still not yet available for individual users:

    Error: This resource can only be used in the context of an organization, "foobar" is a user.
    
      on ../terraform/branch_protection.tf line 1, in resource "github_branch_protection" "branch_protection":
       1: resource "github_branch_protection" "branch_protection" {
    
    
    
    Error: This resource can only be used in the context of an organization, "foobar" is a user.
    
      on ../terraform/branch_protection.tf line 1, in resource "github_branch_protection" "branch_protection":
       1: resource "github_branch_protection" "branch_protection" {

    Perhaps it's planned for this resource to be added in a future release? @jcudit perhaps knows something?

  18. jcudit commented on Sep 14, 2020

    @jcudit
    Contributor

    We revamped the branch protection resource and the changes should be landing in v3.1.0.

  19. modified the milestones: v3.0.0, v3.1.0 on Oct 4, 2020
  20. jcudit commented on Oct 4, 2020

    @jcudit
    Contributor

    I believe this is complete and will be released this week. Please re-open if I've misunderstood.

  21. emmahsax commented on Oct 10, 2020

    @emmahsax
    Author

    Apparently, as of 2020-10-10, version 3.1.0 is not yet released. Do we know what day this is planning to be released?

  22. srobinson commented on Jan 27, 2023

    @srobinson

    This message also appears if your github token has expired. Just FYI and hope it saves someone some time.

  23. nakamura0907 commented on Jan 6, 2024

    @nakamura0907

    Docs overview | integrations/github | Terraform | Terraform Registry

    You must add a required_providers block to every module that will create resources with this provider. If you do not explicitly require integrations/github in a submodule, your terraform run may break in hard-to-troubleshoot ways.

    terraform {
      required_providers {
        github = {
          source  = "integrations/github"
          version = "~> 5.0"
        }
      }
    }
    
    resource "github_team" "this" {
      name                      = var.name
      description               = var.description
      privacy                   = var.privacy
      create_default_maintainer = true 
    }
    
    resource "github_team_membership" "this" {
      for_each = var.members
    
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

    Type: Feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions