Skip to content

Commit

Permalink
docs: readme docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-dfns committed Oct 25, 2024
1 parent a8fd482 commit 80c8615
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 11 deletions.
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,40 @@ networks without needing to open additional ports to the outside networks.

The provider is compatible with HashiCorp Cloud Platform (HCP)

## Available tunnel types

- [AWS Systems Manager (SSM)](https://docs.aws.amazon.com/systems-manager/latest/userguide/)

## Example Usage

```terraform
terraform {
required_providers {
tunnel = {
source = "dfns/tunnel"
version = ">= 1.0.0"
}
}
}
data "tunnel_ssm" "eks" {
target_host = "https://eks-cluster.region.eks.amazonaws.com"
target_port = 443
ssm_instance = "i-instanceid"
ssm_region = "us-east-1"
}
provider "kubernetes" {
host = "https://${data.tunnel_ssm.eks.local_host}:${data.tunnel_ssm.eks.local_port}"
tls_server_name = "eks-cluster.region.eks.amazonaws.com"
client_certificate = file("~/.kube/client-cert.pem")
client_key = file("~/.kube/client-key.pem")
cluster_ca_certificate = file("~/.kube/cluster-ca-cert.pem")
}
```

## Requirements

- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
Expand Down Expand Up @@ -35,10 +69,6 @@ go mod tidy

Then commit the changes to `go.mod` and `go.sum`.

## Using the provider

Fill this in for each provider

## Developing the Provider

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
Expand Down
47 changes: 47 additions & 0 deletions docs/data-sources/ssm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "tunnel_ssm Data Source - tunnel"
subcategory: ""
description: |-
Create a local AWS SSM tunnel to a remote host
---

# tunnel_ssm (Data Source)

Create a local AWS SSM tunnel to a remote host

## Example Usage

```terraform
# The following example shows how to create a tunnel for an AWS RDS database.
data "tunnel_ssm" "rds" {
target_host = "https://my-db.us-east-1.rds.amazonaws.com"
target_port = 443
ssm_instance = "i-instanceid"
ssm_region = "us-east-1"
}
provider "postgresql" {
host = data.tunnel_ssm.rds.local_host
port = data.tunnel_ssm.rds.local_port
database = "my-database"
username = "my-user"
password = "my-password"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `ssm_instance` (String) Specify the exact Instance ID of the managed node to connect to for the session
- `ssm_region` (String) AWS Region where the instance is located
- `target_host` (String) The DNS name or IP address of the remote host
- `target_port` (Number) The port number of the remote host

### Read-Only

- `local_host` (String) The DNS name or IP address of the local host
- `local_port` (Number) The local port number to use for the tunnel
45 changes: 38 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "tunnel Provider"
subcategory: ""
page_title: "Provider: Tunnel"
description: |-
The Tunnel provider is used to manage local network tunnels.
---

# tunnel Provider
# Tunnel Provider

The Tunnel provider is used to manage local network tunnels. This enables users to
securely access and manage remote servers (databases, web servers, etc.) in private
networks without needing to open additional ports to the outside networks.

The provider is compatible with HashiCorp Cloud Platform (HCP)

## Available tunnel types

- [AWS Systems Manager (SSM)](https://docs.aws.amazon.com/systems-manager/latest/userguide/)

<!-- schema generated by tfplugindocs -->
## Schema
## Example Usage

```terraform
terraform {
required_providers {
tunnel = {
source = "dfns/tunnel"
version = ">= 1.0.0"
}
}
}
data "tunnel_ssm" "eks" {
target_host = "https://eks-cluster.region.eks.amazonaws.com"
target_port = 443
ssm_instance = "i-instanceid"
ssm_region = "us-east-1"
}
provider "kubernetes" {
host = "https://${data.tunnel_ssm.eks.local_host}:${data.tunnel_ssm.eks.local_port}"
tls_server_name = "eks-cluster.region.eks.amazonaws.com"
client_certificate = file("~/.kube/client-cert.pem")
client_key = file("~/.kube/client-key.pem")
cluster_ca_certificate = file("~/.kube/cluster-ca-cert.pem")
}
```
16 changes: 16 additions & 0 deletions examples/data-sources/tunnel_ssm/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following example shows how to create a tunnel for an AWS RDS database.

data "tunnel_ssm" "rds" {
target_host = "https://my-db.us-east-1.rds.amazonaws.com"
target_port = 443
ssm_instance = "i-instanceid"
ssm_region = "us-east-1"
}

provider "postgresql" {
host = data.tunnel_ssm.rds.local_host
port = data.tunnel_ssm.rds.local_port
database = "my-database"
username = "my-user"
password = "my-password"
}
25 changes: 25 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
terraform {
required_providers {
tunnel = {
source = "dfns/tunnel"
version = ">= 1.0.0"
}
}
}

data "tunnel_ssm" "eks" {
target_host = "https://eks-cluster.region.eks.amazonaws.com"
target_port = 443
ssm_instance = "i-instanceid"
ssm_region = "us-east-1"
}

provider "kubernetes" {
host = "https://${data.tunnel_ssm.eks.local_host}:${data.tunnel_ssm.eks.local_port}"

tls_server_name = "eks-cluster.region.eks.amazonaws.com"

client_certificate = file("~/.kube/client-cert.pem")
client_key = file("~/.kube/client-key.pem")
cluster_ca_certificate = file("~/.kube/cluster-ca-cert.pem")
}
23 changes: 23 additions & 0 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
page_title: "Provider: Tunnel"
description: |-
The Tunnel provider is used to manage local network tunnels.
---

# Tunnel Provider

The Tunnel provider is used to manage local network tunnels. This enables users to
securely access and manage remote servers (databases, web servers, etc.) in private
networks without needing to open additional ports to the outside networks.

The provider is compatible with HashiCorp Cloud Platform (HCP)

## Available tunnel types

- [AWS Systems Manager (SSM)](https://docs.aws.amazon.com/systems-manager/latest/userguide/)

## Example Usage

{{ tffile "examples/provider/provider.tf" }}

{{- /* No schema in this provider, so no need for this: .SchemaMarkdown | trimspace */ -}}

0 comments on commit 80c8615

Please sign in to comment.