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

[BUG]: Argument repository doesn't pass when used with count on module #2270

Open
1 task done
riupie opened this issue May 22, 2024 · 0 comments
Open
1 task done

[BUG]: Argument repository doesn't pass when used with count on module #2270

riupie opened this issue May 22, 2024 · 0 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@riupie
Copy link

riupie commented May 22, 2024

Expected Behavior

Argument repository should be detected.

Actual Behavior

Argument repository is not detected.

Terraform Version

Terraform v1.8.1
on darwin_arm64

  • provider regsitry.terraform/integrations/github v6.2.1

Affected Resource(s)

  • github_actions_environment_secret

Terraform Configuration Files

No response

Steps to Reproduce

I encounter this issue.
So, I create terraform module to import secret from vault to github environment:

data "github_repository" "repo" {
  full_name = "${var.github_owner}/${var.github_repository}"
}

data "vault_generic_secret" "github_env_secret" {
  path = var.vault_secret_path
}
locals {
  secrets_map = jsondecode(data.vault_generic_secret.github_env_secret.data_json)
}
resource "github_repository_environment" "environment" {
  repository  = var.github_repository
  environment = var.github_environment
}

resource "github_actions_environment_secret" "secrets" {
  count           = length(keys(local.secrets_map))
  repository      = data.github_repository.repo.name
  environment     = github_repository_environment.environment.environment
  secret_name     = element(keys(local.secrets_map), count.index)
  plaintext_value = element(values(local.secrets_map), count.index)
}

And then I use the module on my tf script:

module "github_secret" {
  source             = "path/to/module"
  github_environment = "Test"
  github_repository  = "demo-repo"
  vault_secret_path  = "github/myorg/demo-repo/secrets"
}

Debug Output

╷
│ Error: Missing required argument
│ 
│   with module.github_secret.github_actions_environment_secret.secrets[0],
│   on .terraform/modules/github_secret/github-env-vault/main.tf line 25, in resource "github_actions_environment_secret" "secrets":
│   25:   repository      = data.github_repository.repo.name
│ 
│ The argument "repository" is required, but no definition was found.
╵

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@riupie riupie added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 22, 2024
@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

2 participants