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

[FEAT]: Add a provider function to handle encrypting secrets #2411

Open
1 task done
greg-swift-yohana opened this issue Oct 4, 2024 · 0 comments
Open
1 task done
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@greg-swift-yohana
Copy link

Describe the need

Aside from the lack of documentation (#888), there is a lack of practical usage considering Vault, AWS SSM, Azure Key Vault, 1Password, etc.

Requirements:

  • When pulling a secret from a data source, one should be able to encrypt that data to meet the GitHub API's requirements without running local commands, writing their own customer provider, or any other mechanism.

Recommendation:

As of Terraform 1.8 it is possible for a provider to distribute a custom function that can be leveraged in HCL. This provider should implement that.

How the usage might look (based on example in #888 )

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = ">= 6.3.0"
    }
    vault = {
      source  = "hashicorp/vault"
      version = "4.4.0"
    }
  }
}

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

data "github_actions_public_key" "main" {
  repository = var.repo_name
}

data "vault_kv_secret_v2" "main" {
  mount = "secret"
  name  = "secret/github/repo"
}

resource "github_actions_secret" "main" {
  repository  = var.repo_name
  secret_name = "SECRET_KEY"
  encrypted_value = provider::github::encrypt(
    data.github_actions_public_key.main.key,
    lookup(data.vault_kv_secret_v2.main[0].data, "mysecret", "")
  )
}

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@greg-swift-yohana greg-swift-yohana added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Oct 4, 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 Oct 7, 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: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants