Skip to content

new ephemeral resource: tunnel (port forward) #2700

@geektheripper

Description

@geektheripper

I copied this issue because I am not allowed to reopen it. Terraform 1.10 introduced Ephemeral Resource. Here's an example: sshtunnel_connection (Ephemeral Resource), therefore tunnel support may be possible.

Would you be willing to implement this feature, or at least accept such a PR?

Description

tunnel forward local port to specific kubernetes resource, like what kubectl port-forward do
it helps users to access services[+] in kubernetes like database

Potential Terraform Configuration

ephemeral "kubernetes_tunnel" "postgresql" {
  namespace = "database"
  resource = "deployment/postgresql-deployment"
  port = 5432
}
provider "postgresql" {
  host = ephemeral.kubernetes_tunnel.postgresql.localhost
  port = ephemeral.kubernetes_tunnel.postgresql.localport
# ......
}
ephemeral "kubernetes_tunnel" "minio" {
  namespace = "storage"
  resource = "service/minio-service"
  port = "http"
}
provider "minio" {
  minio_server = "${ephemeral.kubernetes_tunnel.minio.localhost}:${ephemeral.kubernetes_tunnel.minio.localport}"
# ......
}
resource "minio_s3_bucket" "bililive_rec" {
  bucket = "bililive-rec"
  acl = "public-read"
  quota = 109951162777600
}

References

https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/portforward/portforward.go
https://registry.terraform.io/providers/johanneswuerbach/sshtunnel/latest/docs/ephemeral-resources/connection

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions