integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
912 stars 754 forks source link

[BUG]: github_app_installation_repositories allows modifying app for another org #2431

Open a88zach opened 1 month ago

a88zach commented 1 month ago

Expected Behavior

When setting the owner argument for the provider, a github_app_installation_repositories resource should only be allowed to modify app installations for the target Github org

Actual Behavior

When you are using a token that has access to multiple organizations and those organizations have repositories with the same name. You can modify the app installation in one org when targeting the other (repo steps below)

Terraform Version

Terraform v1.9.8 on darwin_arm64

Affected Resource(s)

Terraform Configuration Files

No response

Steps to Reproduce

The outcome will be that the selected repo was removed from the other organization instead of the organization specified in the owner argument of the provider

Debug Output

No response

Panic Output

No response

Code of Conduct

a88zach commented 1 month ago

Where this is really a problem is if you have an app installation in one org with say 10 selected repos. You then create a new github_app_installation_repositories resource for the other org (and forget to update the app installation id in the resource) and set the selected repos to just one (one with same name as a repo in the other org). When you apply, the app installation with 10 selected repos, will now only have the one selected repo