Skip to content

Latest commit

 

History

History
198 lines (147 loc) · 5.75 KB

README.md

File metadata and controls

198 lines (147 loc) · 5.75 KB

ClickHouse Terraform Provider

Docs Dependabot Updates Unit tests

This is the official terraform provider for ClickHouse Cloud.

Usage

You can find examples in the examples/full directory.

Please refer to the official docs for more details.

Breaking changes and deprecations

Upgrading to version >= 3.0.0

In version 3.0.0 we revisited how to deal with clickhouse_service endpoints.

If you are using the clickhouse_service.endpoints_configuration attribute or reading the clickhouse_service.endpoints read only attribute, then you might be affected.

This is a list of all the changes:

  • the endpoints_configuration attribute was removed. Please use the endpoints attribute in a similar fashion. For example if you had
resource "clickhouse_service" "service" {
  ...
  endpoints_configuration = {
    mysql = {
      enabled = true
    }
  }
  ...
}

you need to replace it with

resource "clickhouse_service" "service" {
...
  endpoints = {
    mysql = {
      enabled = true
    }
  }
...
}
  • the endpoints attribute's type changes from a list to a map.

Where before you had:

endpoints = [
  {
    protocol = "https"
    host = "ql5ek38hzz.us-east-2.aws.clickhouse.cloud"
    port: 8443
  },
  {
    protocol: "mysql"
    host: "ql5ek38hzz.us-east-2.aws.clickhouse.cloud",
    port: 3306
  },
  ...
]

Now you'll have:

endpoints = {
  "https": {
    "host": "ql5ek38hzz.us-east-2.aws.clickhouse.cloud",
    "port": 8443
  },
  "mysql": {
    "enabled": false,
    "host": null,
    "port": null
  },
  "nativesecure": {
    "host": "ql5ek38hzz.us-east-2.aws.clickhouse.cloud",
    "port": 9440
  }
}

Upgrading to version >= 1.1.0

In version 1.1.0 we deprecated the min_total_memory_gb and max_total_memory_gb fields. You can keep using them, but they will eventually be removed.

The intended replacement for those fields are:

  • min_replica_memory_gb: Minimum memory used by each replica during auto-scaling
  • max_replica_memory_gb: Maximum memory used by each replica during auto-scaling

The key difference between the old and new fields is that the old ones indicated a total amount of memory for the whole service (the sum of all replicas) while the new ones act on a single replica.

For example, if you had a 3 replica cluster with the following settings:

resource "clickhouse_service" "svc" {
  ...
  min_total_memory_gb = 24
  max_total_memory_gb = 36
}

you should convert it to

resource "clickhouse_service" "svc" {
  ...
  min_replica_memory_gb = 8
  max_replica_memory_gb = 12
}

Upgrading to version >= 1.0.0 of the Clickhouse Terraform Provider

If you are upgrading from version < 1.0.0 to anything >= 1.0.0 and you are using the clickhouse_private_endpoint_registration resource or the private_endpoint_ids attribute of the clickhouse_service resource, then a manual process is required after the upgrade.

  1. In the clickhouse_private_endpoint_registration resource, rename the id attribute to private_endpoint_id.

Before:

resource "clickhouse_private_endpoint_registration" "example" {
  id = aws_vpc_endpoint.pl_vpc_foo.id
  ...
}

After:

resource "clickhouse_private_endpoint_registration" "example" {
  private_endpoint_id = aws_vpc_endpoint.pl_vpc_foo.id
  ...
}
  1. If you used the private_endpoint_ids in any of the clickhouse_service resources

For each service with private_endpoint_ids attribute set:

2a) Create a new clickhouse_service_private_endpoints_attachment resource like this:

resource "clickhouse_service_private_endpoints_attachment" "example" {
  # The ID of the service with the `private_endpoint_ids` set
  service_id = clickhouse_service.aws_red.id

  # the same attribute you previously defined in the `clickhouse_service` resource goes here now
  # Remember to change `id` with `private_endpoint_id` in the `clickhouse_private_endpoint_registration` reference.
  private_endpoint_ids = [clickhouse_private_endpoint_registration.example.private_endpoint_id]
}

2b) Remove the private_endpoint_ids attribute from the clickhouse_service resource.

Example:

Before:

resource "clickhouse_service" "example" {
  ...
  private_endpoint_ids = [clickhouse_private_endpoint_registration.example.id]
}

After:

resource "clickhouse_service" "example" {
  ...
}

resource "clickhouse_service_private_endpoints_attachment" "red_attachment" {
  private_endpoint_ids = [clickhouse_private_endpoint_registration.example.private_endpoint_id]
  service_id = clickhouse_service.example.id
}

If everyting is fine, there should be no changes in existing infrastructure but only one or more clickhouse_service_private_endpoints_attachment should be pending creation. That is the expected status.

If you have trouble, please open an issue and we'll try to help!

Development and contributing

Please read the Development readme