Skip to content

[FEAT]: Get available seats from github_organization data source #3452

@zry98

Description

@zry98

Describe the need

Currently when managing organization membership with this provider, there is no way to detect when the org's seats are full when running terraform plan, but later terraform apply will fail with You must purchase at least one more seat to add this user as a member. [{Resource: Field:user Code:no_seat Message:}], requiring an organization/enterprise owner to manually add seats before rerunning the apply.

Since the GET /orgs/{org} endpoint of GitHub REST API already returns the available seats (seats) and current filled seats (filled_seats) in the plan struct, as documented here, we can expose them to the github_organization data source as attributes, and let users be able to check them with precondition.

GitHub Installation Type

  • GitHub.com (Free, Pro, or Team)
  • GitHub Enterprise Server (on-premises)
  • GitHub Enterprise Cloud with Personal Accounts (github.com)
  • GitHub Enterprise Cloud with Managed Users/EMU (github.com)
  • GitHub Enterprise Cloud with Data Residency (*.ghe.com)
  • I don't know

Relevant log output

* Failed to execute "terraform apply -auto-approve -input=false -lock-timeout=300s -no-color" in ./.terragrunt-cache.../members
  
  Error: PUT https://api.github.com/orgs/my-org/memberships/skywalker: 422 You must purchase at least one more seat to add this user as a member. [{Resource: Field:user Code:no_seat Message:}]
  
    with github_membership.membership["skywalker"],
    on members.tf line 1, in resource "github_membership" "membership":
     1: resource "github_membership" "membership" {

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: FeatureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions