Skip to content
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

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

Closed
emmahsax opened this issue Jun 29, 2020 · 20 comments
Closed

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

emmahsax opened this issue Jun 29, 2020 · 20 comments
Labels
Type: Feature New feature or request
Milestone

Comments

@emmahsax
Copy link

emmahsax commented Jun 29, 2020

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

@anGie44
Copy link
Contributor

anGie44 commented Jun 29, 2020

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 :)

@emmahsax
Copy link
Author

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

@anGie44 anGie44 added the Type: Feature New feature or request label Jun 29, 2020
@jcudit jcudit added this to the v2.9.1 milestone Jul 1, 2020
@jcudit
Copy link
Contributor

jcudit commented Jul 1, 2020

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.

@sogaoh
Copy link

sogaoh commented Jul 1, 2020

@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 ?

@emmahsax
Copy link
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?

@frezbo
Copy link

frezbo commented Aug 8, 2020

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?

@jcudit
Copy link
Contributor

jcudit commented Aug 13, 2020

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.

@dvargas92495
Copy link

dvargas92495 commented Aug 27, 2020

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

@jcudit
Copy link
Contributor

jcudit commented Sep 4, 2020

@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.

@dvargas92495
Copy link

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

@dvargas92495
Copy link

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"
}

@frezbo
Copy link

frezbo commented Sep 11, 2020

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

@emmahsax
Copy link
Author

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

@frezbo
Copy link

frezbo commented Sep 11, 2020

@emmasax4 it's released: https://github.com/terraform-providers/terraform-provider-github/releases/tag/v3.0.0

@emmahsax
Copy link
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?

@jcudit
Copy link
Contributor

jcudit commented Sep 14, 2020

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

@jcudit jcudit modified the milestones: v3.0.0, v3.1.0 Oct 4, 2020
@jcudit
Copy link
Contributor

jcudit commented Oct 4, 2020

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

@jcudit jcudit closed this as completed Oct 4, 2020
@emmahsax
Copy link
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?

@srobinson
Copy link

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

@nakamura0907
Copy link

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
Labels
Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants