Skip to content

Commit 2c4e9d1

Browse files
authored
feat(hipaa/pci): add hipaa/pci compliance type to the service resource (#341)
1 parent ee61f3b commit 2c4e9d1

28 files changed

+576
-2
lines changed

.github/scripts/set_api_env.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ api_key_id="$(echo "${api_env_production}" | jq -r .api_key_id)"
2424
api_key_secret="$(echo "${api_env_production}" | jq -r .api_key_secret)"
2525
if [ "$cloud" != "" ]; then
2626
region="$(echo "${api_env_production}" | jq -rc --arg cloud $cloud '.regions[$cloud]' | jq -c '.[]' | shuf -n 1 |jq -r .)"
27+
compliance_region="$(echo "${api_env_production}" | jq -rc --arg cloud $cloud '.compliance_regions[$cloud]' | jq -c '.[]' | shuf -n 1 |jq -r .)"
2728
fi
2829
;;
2930

@@ -34,6 +35,7 @@ api_key_id="$(echo "${api_env_staging}" | jq -r .api_key_id)"
3435
api_key_secret="$(echo "${api_env_staging}" | jq -r .api_key_secret)"
3536
if [ "$cloud" != "" ]; then
3637
region="$(echo "${api_env_staging}" | jq -rc --arg cloud $cloud '.regions[$cloud]' | jq -c '.[]' | shuf -n 1 |jq -r .)"
38+
compliance_region="$(echo "${api_env_staging}" | jq -rc --arg cloud $cloud '.compliance_regions[$cloud]' | jq -c '.[]' | shuf -n 1 |jq -r .)"
3739
fi
3840
;;
3941

@@ -44,6 +46,7 @@ api_key_id="$(echo "${api_env_development}" | jq -r .api_key_id)"
4446
api_key_secret="$(echo "${api_env_development}" | jq -r .api_key_secret)"
4547
if [ "$cloud" != "" ]; then
4648
region="$(echo "${api_env_development}" | jq -rc --arg cloud $cloud '.regions[$cloud]' | jq -c '.[]' | shuf -n 1 |jq -r .)"
49+
compliance_region="$(echo "${api_env_development}" | jq -rc --arg cloud $cloud '.compliance_regions[$cloud]' | jq -c '.[]' | shuf -n 1 |jq -r .)"
4750
fi
4851
;;
4952

@@ -85,7 +88,10 @@ if [ "${region}" == "" ]; then
8588
if [ "${region}" == "" ]; then
8689
echo "${cloud}_region input must be set when api_env is set to 'Custom'"
8790
exit 1
88-
fi
91+
fi
92+
93+
compliance_region="${region}"
94+
8995
fi
9096
;;
9197
esac
@@ -95,6 +101,8 @@ echo "organization_id=${organization_id}" >> $GITHUB_OUTPUT
95101
echo "api_key_id=${api_key_id}" >> $GITHUB_OUTPUT
96102
echo "api_key_secret=${api_key_secret}" >> $GITHUB_OUTPUT
97103
echo "region='${region}'"
104+
echo "compliance_region='${compliance_region}'"
98105
if [ "$region" != "" ]; then
99106
echo "region=${region}" >> $GITHUB_OUTPUT
107+
echo "compliance_region=${compliance_region}" >> $GITHUB_OUTPUT
100108
fi

.github/workflows/e2e.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ jobs:
9191
uses: actions/checkout@v4
9292
- uses: ./.github/actions/list-examples
9393
id: list
94+
with:
95+
ignore: 'pci'
9496

9597
# Run e2e tests
9698
e2e:
@@ -148,7 +150,7 @@ jobs:
148150
cloud_provider: ${{ matrix.test.cloud }}
149151
upgrade_test: "false"
150152
skip_build: "false"
151-
region: ${{ steps.credentials.outputs.region }}
153+
region: ${{ contains(fromJSON('["hipaa", "pci"]'), matrix.test.name) && steps.credentials.outputs.compliance_region || steps.credentials.outputs.region }}
152154
aws_role_arn: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
153155
- name: cleanup
154156
if: ${{ always() && matrix.test.cloud == 'aws' }}

docs/resources/service.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ resource "clickhouse_service" "service" {
5656
- `backup_configuration` (Attributes) Configuration of service backup settings. (see [below for nested schema](#nestedatt--backup_configuration))
5757
- `backup_id` (String) ID of the backup to restore when creating new service. If specified, the service will be created as a restore operation
5858
- `byoc_id` (String) BYOC ID related to the cloud provider account you want to create this service into.
59+
- `compliance_type` (String) Compliance type of the service. Can be 'hipaa', 'pci'. Required for organizations that wish to deploy their services in the hipaa/pci compliant environment. NOTE: hipaa/pci compliance should be enabled for your ClickHouse organization before using this field.
5960
- `double_sha1_password_hash` (String, Sensitive) Double SHA1 hash of password for connecting with the MySQL protocol. Cannot be specified if `password` is specified.
6061
- `encryption_assumed_role_identifier` (String) Custom role identifier ARN.
6162
- `encryption_key` (String) Custom encryption key ARN.

examples/full/hipaa/aws/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## AWS HIPAA compliant service example
2+
3+
The Terraform code deploys following resources:
4+
- 1 ClickHouse HIPAA compliant service on AWS
5+
6+
The ClickHouse HIPAA compliant service is available from anywhere.
7+
8+
## How to run
9+
10+
- Rename `variables.tfvars.sample` to `variables.tfvars` and fill in all needed data.
11+
- Run `terraform init`
12+
- Run `terraform <plan|apply> -var-file=variables.tfvars`
13+
14+
15+
## Important note
16+
17+
HIPAA compliance should be enabled for your ClickHouse organization.

examples/full/hipaa/aws/main.tf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
variable "organization_id" {
2+
type = string
3+
}
4+
5+
variable "token_key" {
6+
type = string
7+
}
8+
9+
variable "token_secret" {
10+
type = string
11+
}
12+
13+
variable "service_name" {
14+
type = string
15+
default = "My Terraform Service"
16+
}
17+
18+
variable "region" {
19+
type = string
20+
default = "us-east-2"
21+
}
22+
23+
variable "release_channel" {
24+
type = string
25+
default = "default"
26+
validation {
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
29+
}
30+
}
31+
32+
data "clickhouse_api_key_id" "self" {
33+
}
34+
35+
resource "clickhouse_service" "service" {
36+
name = var.service_name
37+
cloud_provider = "aws"
38+
region = var.region
39+
release_channel = var.release_channel
40+
idle_scaling = true
41+
idle_timeout_minutes = 5
42+
password_hash = "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=" # base64 encoded sha256 hash of "test"
43+
44+
ip_access = [
45+
{
46+
source = "0.0.0.0"
47+
description = "Anywhere"
48+
}
49+
]
50+
51+
endpoints = {
52+
mysql = {
53+
enabled = true
54+
}
55+
}
56+
57+
query_api_endpoints = {
58+
api_key_ids = [
59+
data.clickhouse_api_key_id.self.id,
60+
]
61+
roles = [
62+
"sql_console_admin"
63+
]
64+
allowed_origins = null
65+
}
66+
67+
min_replica_memory_gb = 8
68+
max_replica_memory_gb = 120
69+
70+
backup_configuration = {
71+
backup_period_in_hours = 24
72+
backup_retention_period_in_hours = 24
73+
backup_start_time = null
74+
}
75+
76+
compliance_type = "hipaa"
77+
}
78+
79+
output "service_endpoints" {
80+
value = clickhouse_service.service.endpoints
81+
}
82+
83+
output "service_iam" {
84+
value = clickhouse_service.service.iam_role
85+
}

examples/full/hipaa/aws/provider.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is generated automatically please do not edit
2+
terraform {
3+
required_providers {
4+
clickhouse = {
5+
version = "3.5.1"
6+
source = "ClickHouse/clickhouse"
7+
}
8+
}
9+
}
10+
11+
provider "clickhouse" {
12+
organization_id = var.organization_id
13+
token_key = var.token_key
14+
token_secret = var.token_secret
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_providers {
3+
clickhouse = {
4+
version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}"
5+
source = "ClickHouse/clickhouse"
6+
}
7+
}
8+
}
9+
10+
provider "clickhouse" {
11+
organization_id = var.organization_id
12+
token_key = var.token_key
13+
token_secret = var.token_secret
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# these keys are for example only and won't work when pointed to a deployed ClickHouse OpenAPI server
2+
organization_id = "aee076c1-3f83-4637-95b1-ad5a0a825b71"
3+
token_key = "avhj1U5QCdWAE9CA9"
4+
token_secret = "4b1dROiHQEuSXJHlV8zHFd0S7WQj7CGxz5kGJeJnca"

examples/full/hipaa/gcp/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## GCP HIPAA compliant service example
2+
3+
The Terraform code deploys following resources:
4+
- 1 ClickHouse HIPAA compliant service on GCP
5+
6+
The ClickHouse HIPAA compliant service is available from anywhere.
7+
8+
## How to run
9+
10+
- Rename `variables.tfvars.sample` to `variables.tfvars` and fill in all needed data.
11+
- Run `terraform init`
12+
- Run `terraform <plan|apply> -var-file=variables.tfvars`
13+
14+
15+
## Important note
16+
17+
HIPAA compliance should be enabled for your ClickHouse organization.

examples/full/hipaa/gcp/main.tf

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
variable "organization_id" {
2+
type = string
3+
}
4+
5+
variable "token_key" {
6+
type = string
7+
}
8+
9+
variable "token_secret" {
10+
type = string
11+
}
12+
13+
variable "service_name" {
14+
type = string
15+
default = "My Terraform Service"
16+
}
17+
18+
variable "region" {
19+
type = string
20+
default = "us-central1"
21+
}
22+
23+
variable "release_channel" {
24+
type = string
25+
default = "default"
26+
validation {
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
29+
}
30+
}
31+
32+
data "clickhouse_api_key_id" "self" {
33+
}
34+
35+
resource "clickhouse_service" "service" {
36+
name = var.service_name
37+
cloud_provider = "gcp"
38+
region = var.region
39+
release_channel = var.release_channel
40+
idle_scaling = true
41+
idle_timeout_minutes = 5
42+
password_hash = "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=" # base64 encoded sha256 hash of "test"
43+
44+
ip_access = [
45+
{
46+
source = "0.0.0.0"
47+
description = "Anywhere"
48+
}
49+
]
50+
51+
endpoints = {
52+
mysql = {
53+
enabled = true
54+
}
55+
}
56+
57+
query_api_endpoints = {
58+
api_key_ids = [
59+
data.clickhouse_api_key_id.self.id,
60+
]
61+
roles = [
62+
"sql_console_admin"
63+
]
64+
allowed_origins = null
65+
}
66+
67+
min_replica_memory_gb = 8
68+
max_replica_memory_gb = 120
69+
70+
backup_configuration = {
71+
backup_retention_period_in_hours = 48
72+
}
73+
74+
compliance_type = "hipaa"
75+
}
76+
77+
output "service_endpoints" {
78+
value = clickhouse_service.service.endpoints
79+
}
80+
81+
output "service_iam" {
82+
value = clickhouse_service.service.iam_role
83+
}

0 commit comments

Comments
 (0)