Skip to content

Commit

Permalink
Configure IP whitelist for a cluster (#91)
Browse files Browse the repository at this point in the history
This implements the IP whitelisting API to configure authorized network
to connect on a Camunda cluster.
  • Loading branch information
multani authored Nov 14, 2023
1 parent 1c82154 commit 8c8ca4f
Show file tree
Hide file tree
Showing 11 changed files with 624 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ jobs:
- uses: actions/checkout@v3
- run: go mod download
- env:
TF_ACC: "1"
TF_ACC: "0"
run: go test -v -cover ./internal/provider/
timeout-minutes: 10
91 changes: 91 additions & 0 deletions docs/resources/cluster_ip_whitelist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
page_title: "camunda_cluster_ip_whitelist Resource - terraform-provider-camunda"
subcategory: ""
description: |-
Manage IP whitelists of a Camunda cluster
---

# camunda_cluster_ip_whitelist (Resource)

Manage IP whitelists of a Camunda cluster

This configure a cluster IP whitelist to authorize only the specified IP addresses to connect to the Camunda cluster.

~> **Note** Although you can create multiple instances of this resource for a
single cluster, they will overwrite each other in a random manner.
Instead, create a single `camunda_cluster_ip_whitelist` resource per-cluster, and configures
multiple `ip_whitelist` blocks inside this `camunda_cluster_ip_whitelist` resource.

## Example Usage

```terraform
# The channel containing the most recent version of Zeebe.
data "camunda_channel" "alpha" {
name = "Alpha"
}
# A cluster plan type for default trials.
data "camunda_cluster_plan_type" "trial" {
name = "Trial Cluster"
}
# An available region
data "camunda_region" "europe" {
name = "Belgium, Europe (europe-west1)"
}
resource "camunda_cluster" "test" {
name = "test"
channel = data.camunda_channel.alpha.id
generation = data.camunda_channel.alpha.default_generation_id
region = data.camunda_region.europe.id
plan_type = data.camunda_cluster_plan_type.trial.id
}
resource "camunda_cluster_ip_whitelist" "test" {
cluster_id = camunda_cluster.test.id
# These IP whitelists are likely to prevent from connecting to your cluster :)
ip_whitelist {
ip = "127.0.0.1"
description = "localhost"
}
ip_whitelist {
ip = "192.168.0.0/24"
description = "local network"
}
ip_whitelist {
ip = "192.168.0.1"
# no description
}
}
```

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

### Required

- `cluster_id` (String) Cluster ID

### Optional

- `ip_whitelist` (Block Set) (see [below for nested schema](#nestedblock--ip_whitelist))

### Read-Only

- `id` (String) ID

<a id="nestedblock--ip_whitelist"></a>
### Nested Schema for `ip_whitelist`

Required:

- `ip` (String) The IP address/network to whitelist. Must be a valid IPv4 address/network (such as `10.0.0.1` or `172.42.0.0/24`)

Optional:

- `description` (String) A short description for this IP whitelist.
24 changes: 22 additions & 2 deletions examples/resources/camunda_cluster/provider.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
variable "camunda_client_id" {}
variable "camunda_client_secret" {}
variable "camunda_client_id" {
default = "KGNwvEgmGEWskRON"
}

variable "camunda_client_secret" {
default = "zrIsrYWp.HgYOg2eAgIuI~2_AtkmQqFr"
}

variable "camunda_api_url" {
default = "https://api.cloud.camunda.io"
}

variable "camunda_audience" {
default = "api.cloud.camunda.io"
}

variable "camunda_token_url" {
default = "https://login.cloud.camunda.io/oauth/token"
}

terraform {
required_providers {
Expand All @@ -10,6 +27,9 @@ terraform {
}

provider "camunda" {
api_url = var.camunda_api_url
audience = var.camunda_audience
client_id = var.camunda_client_id
client_secret = var.camunda_client_secret
token_url = var.camunda_token_url
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions examples/resources/camunda_cluster_ip_whitelist/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
variable "camunda_client_id" {
default = "KGNwvEgmGEWskRON"
}

variable "camunda_client_secret" {
default = "zrIsrYWp.HgYOg2eAgIuI~2_AtkmQqFr"
}

variable "camunda_api_url" {
default = "https://api.cloud.camunda.io"
}

variable "camunda_audience" {
default = "api.cloud.camunda.io"
}

variable "camunda_token_url" {
default = "https://login.cloud.camunda.io/oauth/token"
}

terraform {
required_providers {
camunda = {
source = "multani/camunda"
}
}
}

provider "camunda" {
api_url = var.camunda_api_url
audience = var.camunda_audience
client_id = var.camunda_client_id
client_secret = var.camunda_client_secret
token_url = var.camunda_token_url
}
43 changes: 43 additions & 0 deletions examples/resources/camunda_cluster_ip_whitelist/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# The channel containing the most recent version of Zeebe.
data "camunda_channel" "alpha" {
name = "Alpha"
}

# A cluster plan type for default trials.
data "camunda_cluster_plan_type" "trial" {
name = "Trial Cluster"
}

# An available region
data "camunda_region" "europe" {
name = "Belgium, Europe (europe-west1)"
}

resource "camunda_cluster" "test" {
name = "test"

channel = data.camunda_channel.alpha.id
generation = data.camunda_channel.alpha.default_generation_id
region = data.camunda_region.europe.id
plan_type = data.camunda_cluster_plan_type.trial.id
}

resource "camunda_cluster_ip_whitelist" "test" {
cluster_id = camunda_cluster.test.id

# These IP whitelists are likely to prevent from connecting to your cluster :)
ip_whitelist {
ip = "127.0.0.1"
description = "localhost"
}

ip_whitelist {
ip = "192.168.0.0/24"
description = "local network"
}

ip_whitelist {
ip = "192.168.0.1"
# no description
}
}
Loading

0 comments on commit 8c8ca4f

Please sign in to comment.