Skip to content

[BUG]: Imports of github_actions_environment_variable Broken #3213

@kyledecot

Description

@kyledecot

Expected Behavior

If I have an existing environment in which some of the environment variables exist in Github and some do not yet exist running a apply should import existing resources and create missing resources.

Actual Behavior

Currently if the for_each block of an import points to a environment variable which does not yet exist apply will exit w/ a 404 instead of gracefully continuing and prompting that the resource will be created.

Terraform Version

Terraform v1.14.5
on darwin_arm64

Affected Resource(s)

  • github_actions_environment_variable

Terraform Configuration Files

locals {
  variables = {
    FOO = "bar" # already exists (should be imported)
    HELLO = "world" # does not yet exist (should be created)
  }
}

import {
  for_each = local.variables

  id = "repo/staging/${each.key}"
  to = github_actions_environment_variable.variables[each.key]
}

resource "github_actions_environment_variable" "variables" {
  for_each = local.variables

  environment   = "staging"
  value         = each.value
  repository    = "repo"
  variable_name = each.key
}

Steps to Reproduce

terraform apply

Debug Output

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

╷
│ Error: GET https://api.github.com/repos/org/repo/environments/staging/variables/HELLO: 404 Not Found []

Panic Output

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: BugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions