Skip to content

Fix github_actions_hosted_runner import of the image block#3406

Open
terrabitz wants to merge 4 commits into
integrations:mainfrom
terrabitz:terrabitz/fix-github-hosted-runner-image-import
Open

Fix github_actions_hosted_runner import of the image block#3406
terrabitz wants to merge 4 commits into
integrations:mainfrom
terrabitz:terrabitz/fix-github-hosted-runner-image-import

Conversation

@terrabitz
Copy link
Copy Markdown

Resolves #3405


Before the change?

During imports, the github_actions_hosted_runner resource tried accessing incorrect JSON keys, resulting in the image block not being imported correctly. This in turn causes the resource to be replaced, since this is an immutable value:

Terraform will perform the following actions:

  # github_actions_hosted_runner.my_example_runner must be replaced
  # (imported from "1")
  # Warning: this will destroy the imported resource
-/+ resource "github_actions_hosted_runner" "my_example_runner" {
      ~ id                   = "1" -> (known after apply)
        image_gen            = false
      ~ last_active_on       = "2026-05-06T16:27:22.8271735Z" -> (known after apply)
      ~ machine_size_details = [
          - {
              - cpu_cores  = 2
              - id         = "2-core"
              - memory_gb  = 8
              - storage_gb = 75
            },
        ] -> (known after apply)
        maximum_runners      = 50
        name                 = "my-example-runner"
      ~ platform             = "linux-x64" -> (known after apply)
        public_ip_enabled    = false
      ~ public_ips           = [] -> (known after apply)
        runner_group_id      = 1
        size                 = "2-core"
      ~ status               = "Ready" -> (known after apply)

      + image { # forces replacement
          + id      = "2306"
          + size_gb = (known after apply)
          + source  = "github"
        }
    }

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

After the change?

The correct JSON keys are now used, and the resource imports correctly

Terraform will perform the following actions:

  # github_actions_hosted_runner.my_example_runner will be imported
    resource "github_actions_hosted_runner" "my_example_runner" {
        id                   = "1"
        image_gen            = false
        last_active_on       = "2026-05-06T16:27:22.8271735Z"
        machine_size_details = [
            {
                cpu_cores  = 2
                id         = "2-core"
                memory_gb  = 8
                storage_gb = 75
            },
        ]
        maximum_runners      = 50
        name                 = "my-example-runner"
        platform             = "linux-x64"
        public_ip_enabled    = false
        public_ips           = []
        runner_group_id      = 1
        size                 = "2-core"
        status               = "Ready"

        image {
            id      = "2306"
            size_gb = 75
            source  = "github"
        }
    }

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

Pull request checklist

  • Schema migrations have been created if needed (example)
  • 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

I think this bug occurred because the GitHub documentation for the "get a hosted runner for an organization" endpoint lies.

Here is a example of what the output from the /orgs/<org>/actions/hosted-runners/<id> endpoint looks like:

{
  "id": 8,
  "name": "my-example-runner",
  "image_details": {
    "id": "2306",
    "size_gb": 75,
    "display_name": "Ubuntu Latest (24.04)",
    "source": "github",
    "version": "latest"
  },
  "platform": "linux-x64",
  "runner_group_id": 1,
  "maximum_runners": 50,
  "machine_size_details": {
    "id": "2-core",
    "cpu_cores": 2,
    "memory_gb": 8,
    "storage_gb": 75
  },
  "public_ip_enabled": false,
  "public_ips": [],
  "last_active_on": "2026-05-06T16:27:22.8271735Z",
  "status": "Ready",
  "image_gen": false
}

Notably, it does not contain a key called image, but rather image_details. Also that block doesn't have a size, but rather size_gb

This matches up with the listed schema but not the listed Example response. I wonder if GitHub changed their APIs and forgot to update the example.

Note

Note to reviewer, I wasn't able to run the integration tests locally because it requires an enterprise account to use this feature. And unfortunately I can't use my company's organization, since we don't have a dedicated organization for testing this. But I have tested the imports locally through a local provider override.

terrabitz added 2 commits May 6, 2026 13:53
Signed-off-by: Trevor Taubitz <trevor.taubitz@flocksafety.com>
Signed-off-by: Trevor Taubitz <trevor.taubitz@flocksafety.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

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]: github_actions_hosted_runner resource must be replaced after import

1 participant