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

fix(resource_github_release): Handle missing release in read #2115

Conversation

arunsathiya
Copy link
Contributor

@arunsathiya arunsathiya commented Jan 25, 2024

Resolves #1864


Before the change?

  • When a GitHub release is deleted manually (outside of Terraform state), resource_github_release doesn't handle that situation and throws an error. Example:
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/arun/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
╵
github_repository.example: Refreshing state... [id=repo-terraform]
github_release.example: Refreshing state... [id=138562207]

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: GET https://api.github.com/repos/arunsathiya/repo-terraform/releases/138562207: 404 Not Found []
│
│   with github_release.example,
│   on main.tf line 46, in resource "github_release" "example":
│   46: resource "github_release" "example" {
│
╵

After the change?

  • resource_github_release now appropriately learns that the release is missing and informs Terraform state.
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/arun/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
╵
tgithub_repository.example: Refreshing state... [id=repo-terraform]
 github_release.example: Refreshing state... [id=138566317]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # github_release.example will be created
  + resource "github_release" "example" {
      + draft                  = false
      + etag                   = (known after apply)
      + generate_release_notes = false
      + id                     = (known after apply)
      + name                   = "example"
      + prerelease             = true
      + repository             = "repo-terraform"
      + tag_name               = "v1.0.3"
      + target_commitish       = "main"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kfcampbell kfcampbell merged commit 9008816 into integrations:main Feb 5, 2024
3 checks passed
@arunsathiya arunsathiya deleted the fix/1864-handle-manually-deleted-github-release-state branch February 6, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Provider fails whenever a github_release is manually deleted from GitHub
2 participants