integrations / terraform-provider-github

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

[BUG]: App Token not passing to child module #2230

Open coreyd-valcre opened 5 months ago

coreyd-valcre commented 5 months ago

Expected Behavior

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 3.80.0"
    }
    azuread = {
      source  = "hashicorp/azuread"
      version = ">= 2.47.0"
    }
    github = {
      source  = "integrations/github"
      version = "~> 6.0"
    }
  }
}

provider "azurerm" {
  features {
    resource_group {
      prevent_deletion_if_contains_resources = false
    }
    key_vault {
      purge_soft_delete_on_destroy = true
    }
  }
  skip_provider_registration = false
}

provider "azuread" {

}

provider "github" {
  token = var.github_token
  owner = "SecretCo"
}

module "gha-dpl-env-client-id-add" {
  depends_on      = [module.gha-dpl-identity-sp]
  source          = "git::https://github.com/SecretCo/SecretRepo.git//Github/Actions/Environment/Secret?ref=feature/github-secret"
  repository_name = "SecretRepo"
  environment     = "development"
  secret_name     = "AZURE_CLIENT_ID"
  secret_value    = module.gha-dpl-identity-sp.service_principal_id
}

This should connect to the secret (also variable in a seperate module doing the same thing) module in the child and create my secret.

Actual Behavior

I recieve a 404 on the repo as it does not seem to be passing the token to the child module. Note that in the child module I do have:

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 6.0"
    }
  }
}

Listed so it knows to use the correct github. If I add a provider block in the child, it acts as if it is using the hashicorp source until I remove it. No matter what changes I make I cannot seem to get around the 404 and I am not sure what additional steps to take to ensure that my token is passed properly.

Do note, I am logging in using a Github App and converting the app_id and app_password to a token which does log into the CLI in an earlier phase.

Terraform Version

Terraform 1.8.0 on darwin arm64 (MACOS)

Affected Resource(s)

Terraform Configuration Files

No response

Steps to Reproduce

terraform apply -tfplan ./tfplan

Debug Output

2024-04-12T16:11:36.9939336Z 2024-04-12T16:11:19.366Z [ERROR] provider.terraform-provider-github_v6.2.1: Response contains error diagnostic: diagnostic_severity=ERROR diagnostic_summary="GET https://api.github.com/repos/SecretCo/MyRepo: 404 Not Found []" tf_provider_addr=provider tf_req_id=2a45f0d2-a6b3-c79c-3aa0-bf314fdf6b9f tf_resource_type=github_actions_environment_secret @caller=github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_detail="" tf_rpc=ApplyResourceChange tf_proto_version=5.4 @module=sdk.proto timestamp=2024-04-12T16:11:19.366Z

2024-04-12T16:11:36.9961465Z 2024-04-12T16:11:19.367Z [ERROR] vertex "module.gha-dpl-env-client-id-add.github_actions_environment_secret.secret" error: GET https://api.github.com/repos/SecretCo/SecretRepo: 404 Not Found []

Panic Output

No response

Code of Conduct