diff --git a/docs/index.md b/docs/index.md index a7de19a..1e3f7b2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,12 +3,181 @@ page_title: "risingwavecloud Provider" subcategory: "" description: |- + The Terraform plugin for RisingWave Cloud https://cloud.risingwave.com/ allows you to manage your resources + on the RisingWave Cloud platform with Terraform. + This project is under heavy development. Please join our + Slack https://join.slack.com/t/risingwave-community/shared_invite/zt-1jei7dk79-fguGadPI2KnhtWnnxBVGoA to get the latest information. + Quick Start + ```hcl + Install Terraform provider for RisingWave Cloud + terraform { + required_providers { + risingwavecloud = { + source = "risingwavelabs/risingwavecloud" + version = + } + } + } + Configure the RisingWave Cloud provider + provider "risingwavecloud" { + apikey = + apisecret = + } + Create a RisingWave Cluster + resource "risingwavecloudcluster" "mycluster" { + name = "mycluster" + version = "v1.7.1" + region = "us-east-1" + spec = { + risingwaveconfig = "" + compute = { + defaultnodegroup = { + cpu = "0.5" + memory = "2 GB" + } + } + compactor = { + defaultnodegroup = { + cpu = "1" + memory = "4 GB" + } + } + meta = { + defaultnodegroup = { + cpu = "0.5" + memory = "2 GB" + } + etcdmetastore = { + defaultnodegroup = { + cpu = "0.5" + memory = "2 GB" + } + } + } + frontend = { + defaultnodegroup = { + cpu = "0.5" + memory = "2 GB" + } + } + } + }``` + Authentication + The API key and API secret are created at the RisingWave Cloud portal https://cloud.risingwave.com/. + Note that you can also use environment variables to set the API key and API secret: + hcl + RWC_API_KEY=myapikeyvalue + RWC_API_SECRET=myapisecretvalue + This allows you to manage your credentials in a more secure way. + Import Resources + You can import existing resources into Terraform using the terraform import command. + To import a resource, you need to know the resource ID to let the provider know which resource to fetch from + the RisingWave Cloud platform. Read the documentation of each resource to know how to get its ID. + For more details about this command, check the Terraform documentation https://developer.hashicorp.com/terraform/cli/import. + Feature Requests + Please join our + Slack https://join.slack.com/t/risingwave-community/shared_invite/zt-1jei7dk79-fguGadPI2KnhtWnnxBVGoA to request new features. + Reporting Issues + Please report any issues at the GitHub repository https://github.com/risingwavelabs/terraform-provider-risingwavecloud. --- # risingwavecloud Provider +The Terraform plugin for [RisingWave Cloud](https://cloud.risingwave.com/) allows you to manage your resources +on the RisingWave Cloud platform with Terraform. +**This project is under heavy development. Please join our +[Slack](https://join.slack.com/t/risingwave-community/shared_invite/zt-1jei7dk79-fguGadPI2KnhtWnnxBVGoA) to get the latest information.** + +## Quick Start + +```hcl +# Install Terraform provider for RisingWave Cloud +terraform { + required_providers { + risingwavecloud = { + source = "risingwavelabs/risingwavecloud" + version = + } + } +} + +# Configure the RisingWave Cloud provider +provider "risingwavecloud" { + api_key = + api_secret = +} + +# Create a RisingWave Cluster +resource "risingwavecloud_cluster" "my_cluster" { + name = "my_cluster" + version = "v1.7.1" + region = "us-east-1" + spec = { + risingwave_config = "" + compute = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + } + compactor = { + default_node_group = { + cpu = "1" + memory = "4 GB" + } + } + meta = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + etcd_meta_store = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + } + } + frontend = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + } + } +} +``` + + +## Authentication +The API key and API secret are created at the [RisingWave Cloud portal](https://cloud.risingwave.com/). + +Note that you can also use environment variables to set the API key and API secret: +```hcl +RWC_API_KEY=myapikeyvalue +RWC_API_SECRET=myapisecretvalue +``` +This allows you to manage your credentials in a more secure way. + + +## Import Resources +You can import existing resources into Terraform using the `terraform import` command. + +To import a resource, you need to know the resource ID to let the provider know which resource to fetch from +the RisingWave Cloud platform. Read the documentation of each resource to know how to get its ID. + +For more details about this command, check the [Terraform documentation](https://developer.hashicorp.com/terraform/cli/import). + + +## Feature Requests +Please join our +[Slack](https://join.slack.com/t/risingwave-community/shared_invite/zt-1jei7dk79-fguGadPI2KnhtWnnxBVGoA) to request new features. + + +## Reporting Issues +Please report any issues at the [GitHub repository](https://github.com/risingwavelabs/terraform-provider-risingwavecloud). ## Example Usage diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 3f51914..d9a3bc2 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -3,12 +3,125 @@ page_title: "risingwavecloud_cluster Resource - terraform-provider-risingwavecloud" subcategory: "" description: |- - A RisingWave Cluster + A managed RisingWave Cluster on the RisingWave Cloud platform. + Import a RisingWave Cluster + To import a RisingWave cluster, follow the steps below: + Get the UUID of the cluster from the RisingWave Cloud platform.Write a resource definition to import the cluster. For example: + ```hcl + resource "risingwavecloudcluster" "mycluster" { + region = "us-east-1" + name = "mycluster" + version = "v1.8.0" + spec = { + compute = { + defaultnodegroup = { + cpu = "2" + memory = "8 GB" + replica = 1 + } + } + compactor = { + defaultnodegroup = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + frontend = { + defaultnodegroup = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + meta = { + defaultnodegroup = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + etcdmetastore = { + defaultnode_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + } + } + } + ``` + Note that 1 RWU is equivalent to 1 vCPU and 4 GB of memory. + Run the import command: + shell + terraform import risingwavecloud_cluster.my_cluster --- # risingwavecloud_cluster (Resource) -A RisingWave Cluster +A managed RisingWave Cluster on the RisingWave Cloud platform. + +## Import a RisingWave Cluster + +To import a RisingWave cluster, follow the steps below: + +1. Get the UUID of the cluster from the RisingWave Cloud platform. + +2. Write a resource definition to import the cluster. For example: + + ```hcl + resource "risingwavecloud_cluster" "my_cluster" { + region = "us-east-1" + name = "my_cluster" + version = "v1.8.0" + spec = { + compute = { + default_node_group = { + cpu = "2" + memory = "8 GB" + replica = 1 + } + } + compactor = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + frontend = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + meta = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + etcd_meta_store = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + } + } + } + + ``` + +Note that 1 RWU is equivalent to 1 vCPU and 4 GB of memory. + +3. Run the import command: + + ```shell + terraform import risingwavecloud_cluster.my_cluster + ``` diff --git a/docs/resources/cluster_user.md b/docs/resources/cluster_user.md index 1230d1d..f22043d 100644 --- a/docs/resources/cluster_user.md +++ b/docs/resources/cluster_user.md @@ -3,12 +3,49 @@ page_title: "risingwavecloud_cluster_user Resource - terraform-provider-risingwavecloud" subcategory: "" description: |- - A database user in a RisingWave cluster. + A database user in a RisingWave cluster. The username and password of the dabase user are used to + connect to the RisingWave cluster. + Import a Cluster User + To import a cluster user, follow the steps below: + Get the UUID of the corrsponding cluster from the RisingWave Cloud platform.Write a resource definition to import the cluster user. For example: + hcl + resource "risingwavecloud_cluster_user" "test" { + cluster_id = "cluster-id" + username = "test-user" + password = "test-password" + } + + Run the import command: + shell + terraform import risingwavecloud_cluster_user.test . --- # risingwavecloud_cluster_user (Resource) -A database user in a RisingWave cluster. +A database user in a RisingWave cluster. The username and password of the dabase user are used to +connect to the RisingWave cluster. + +## Import a Cluster User + +To import a cluster user, follow the steps below: + +1. Get the UUID of the corrsponding cluster from the RisingWave Cloud platform. + +2. Write a resource definition to import the cluster user. For example: + +```hcl + resource "risingwavecloud_cluster_user" "test" { + cluster_id = "cluster-id" + username = "test-user" + password = "test-password" + } + ``` + +3. Run the import command: + +```shell +terraform import risingwavecloud_cluster_user.test . +``` diff --git a/docs/resources/privatelink.md b/docs/resources/privatelink.md index 4dc3919..33cd4c8 100644 --- a/docs/resources/privatelink.md +++ b/docs/resources/privatelink.md @@ -3,12 +3,56 @@ page_title: "risingwavecloud_privatelink Resource - terraform-provider-risingwavecloud" subcategory: "" description: |- - A Private Link connection + A Private Link connection on the RisingWave Cloud platform. + In AWS, it is a configured endpoint to connect to a VPC endpoint service in your VPC. + In GCP, it is a endpoint to a service attachment in your private network. + Learn more details about this resource at RisingWave Cloud Documentation https://docs.risingwave.com/cloud/create-a-connection/. + Import a Privatelink Resource + To import a Privatelink resource, follow the steps below: + Get the UUID of the privatelink from the RisingWave Cloud platform.Write a resource definition to import the cluster. For example: + hcl + resource "risingwavecloud_privatelink" "test" { + cluster_id = "cluster-id" + connection_name = "test-connection" + target = "test-target" + } + + Run the import command: + shell + terraform import risingwavecloud_privatelink.test --- # risingwavecloud_privatelink (Resource) -A Private Link connection +A Private Link connection on the RisingWave Cloud platform. + +In AWS, it is a configured endpoint to connect to a VPC endpoint service in your VPC. + +In GCP, it is a endpoint to a service attachment in your private network. + +Learn more details about this resource at [RisingWave Cloud Documentation](https://docs.risingwave.com/cloud/create-a-connection/). + +## Import a Privatelink Resource + +To import a Privatelink resource, follow the steps below: + +1. Get the UUID of the privatelink from the RisingWave Cloud platform. + +2. Write a resource definition to import the cluster. For example: + +```hcl + resource "risingwavecloud_privatelink" "test" { + cluster_id = "cluster-id" + connection_name = "test-connection" + target = "test-target" + } + ``` + +3. Run the import command: + +```shell +terraform import risingwavecloud_privatelink.test +``` diff --git a/examples/resources/cluster_user/resource.tf b/examples/resources/cluster_user/resource.tf new file mode 100644 index 0000000..0fb95e2 --- /dev/null +++ b/examples/resources/cluster_user/resource.tf @@ -0,0 +1,5 @@ +resource "risingwavecloud_cluster_user" "test" { + cluster_id = "cluster-id" + username = "test-user" + password = "test-password" +} diff --git a/examples/resources/privatelink/resource.tf b/examples/resources/privatelink/resource.tf new file mode 100644 index 0000000..1e7528a --- /dev/null +++ b/examples/resources/privatelink/resource.tf @@ -0,0 +1,5 @@ +resource "risingwavecloud_privatelink" "test" { + cluster_id = "cluster-id" + connection_name = "test-connection" + target = "test-target" +} diff --git a/internal/provider/doc.go b/internal/provider/doc.go new file mode 100644 index 0000000..42e7aa7 --- /dev/null +++ b/internal/provider/doc.go @@ -0,0 +1,223 @@ +package provider + +var providerMarkdownDescription = ` +The Terraform plugin for [RisingWave Cloud](https://cloud.risingwave.com/) allows you to manage your resources +on the RisingWave Cloud platform with Terraform. + +**This project is under heavy development. Please join our +[Slack](https://join.slack.com/t/risingwave-community/shared_invite/zt-1jei7dk79-fguGadPI2KnhtWnnxBVGoA) to get the latest information.** + +## Quick Start + +` + "```hcl" + ` +# Install Terraform provider for RisingWave Cloud +terraform { + required_providers { + risingwavecloud = { + source = "risingwavelabs/risingwavecloud" + version = + } + } +} + +# Configure the RisingWave Cloud provider +provider "risingwavecloud" { + api_key = + api_secret = +} + +# Create a RisingWave Cluster +resource "risingwavecloud_cluster" "my_cluster" { + name = "my_cluster" + version = "v1.7.1" + region = "us-east-1" + spec = { + risingwave_config = "" + compute = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + } + compactor = { + default_node_group = { + cpu = "1" + memory = "4 GB" + } + } + meta = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + etcd_meta_store = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + } + } + frontend = { + default_node_group = { + cpu = "0.5" + memory = "2 GB" + } + } + } +} +` + "```" + ` + + +## Authentication +The API key and API secret are created at the [RisingWave Cloud portal](https://cloud.risingwave.com/). + +Note that you can also use environment variables to set the API key and API secret: +` + "```hcl" + ` +RWC_API_KEY=myapikeyvalue +RWC_API_SECRET=myapisecretvalue +` + "```" + ` +This allows you to manage your credentials in a more secure way. + + +## Import Resources +You can import existing resources into Terraform using the ` + "`" + `terraform import` + "`" + ` command. + +To import a resource, you need to know the resource ID to let the provider know which resource to fetch from +the RisingWave Cloud platform. Read the documentation of each resource to know how to get its ID. + +For more details about this command, check the [Terraform documentation](https://developer.hashicorp.com/terraform/cli/import). + + +## Feature Requests +Please join our +[Slack](https://join.slack.com/t/risingwave-community/shared_invite/zt-1jei7dk79-fguGadPI2KnhtWnnxBVGoA) to request new features. + + +## Reporting Issues +Please report any issues at the [GitHub repository](https://github.com/risingwavelabs/terraform-provider-risingwavecloud). +` + +var clusterMarkdownDescription = ` +A managed RisingWave Cluster on the RisingWave Cloud platform. + +## Import a RisingWave Cluster + +To import a RisingWave cluster, follow the steps below: + +1. Get the UUID of the cluster from the RisingWave Cloud platform. + +2. Write a resource definition to import the cluster. For example: + +` + " ```hcl" + ` + resource "risingwavecloud_cluster" "my_cluster" { + region = "us-east-1" + name = "my_cluster" + version = "v1.8.0" + spec = { + compute = { + default_node_group = { + cpu = "2" + memory = "8 GB" + replica = 1 + } + } + compactor = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + frontend = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + meta = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + etcd_meta_store = { + default_node_group = { + cpu = "1" + memory = "4 GB" + replica = 1 + } + } + } + } + } + +` + " ```" + ` + +Note that 1 RWU is equivalent to 1 vCPU and 4 GB of memory. + +3. Run the import command: + +` + " ```shell" + ` + terraform import risingwavecloud_cluster.my_cluster +` + " ```" + ` +` + +var privateLinkMarkdownDescription = ` +A Private Link connection on the RisingWave Cloud platform. + +In AWS, it is a configured endpoint to connect to a VPC endpoint service in your VPC. + +In GCP, it is a endpoint to a service attachment in your private network. + +Learn more details about this resource at [RisingWave Cloud Documentation](https://docs.risingwave.com/cloud/create-a-connection/). + +## Import a Privatelink Resource + +To import a Privatelink resource, follow the steps below: + +1. Get the UUID of the privatelink from the RisingWave Cloud platform. + +2. Write a resource definition to import the cluster. For example: + +` + "```hcl" + ` + resource "risingwavecloud_privatelink" "test" { + cluster_id = "cluster-id" + connection_name = "test-connection" + target = "test-target" + } + ` + "```" + ` + +3. Run the import command: + +` + "```shell" + ` +terraform import risingwavecloud_privatelink.test +` + "```" + ` +` + +var clusterUserMarkdownDescription = ` +A database user in a RisingWave cluster. The username and password of the dabase user are used to +connect to the RisingWave cluster. + +## Import a Cluster User + +To import a cluster user, follow the steps below: + +1. Get the UUID of the corrsponding cluster from the RisingWave Cloud platform. + +2. Write a resource definition to import the cluster user. For example: + +` + "```hcl" + ` + resource "risingwavecloud_cluster_user" "test" { + cluster_id = "cluster-id" + username = "test-user" + password = "test-password" + } + ` + "```" + ` + +3. Run the import command: + +` + "```shell" + ` +terraform import risingwavecloud_cluster_user.test . +` + "```" + ` +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index fe6b964..c2d86fe 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -42,6 +42,8 @@ func (p *RisingWaveCloudProvider) Metadata(ctx context.Context, req provider.Met func (p *RisingWaveCloudProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ + Description: "The Terraform plugin for https://cloud.risingwave.com allows you to manage your resources on the RisingWave Cloud platform with Terraform.", + MarkdownDescription: providerMarkdownDescription, Attributes: map[string]schema.Attribute{ "endpoint": schema.StringAttribute{ MarkdownDescription: "The endpoint of the RisingWave Cloud API server. This is only used for testing.", diff --git a/internal/provider/resource_cluster.go b/internal/provider/resource_cluster.go index ef90f57..c36f858 100644 --- a/internal/provider/resource_cluster.go +++ b/internal/provider/resource_cluster.go @@ -162,7 +162,8 @@ func (r *ClusterResource) Schema(ctx context.Context, req resource.SchemaRequest } resp.Schema = schema.Schema{ - MarkdownDescription: "A RisingWave Cluster", + Description: "A managed RisingWave Cluster on the RisingWave Cloud platform", + MarkdownDescription: clusterMarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ MarkdownDescription: "The NsID (namespace id) of the cluster.", diff --git a/internal/provider/resource_cluster_user.go b/internal/provider/resource_cluster_user.go index 03c2cf6..bc0ca1b 100644 --- a/internal/provider/resource_cluster_user.go +++ b/internal/provider/resource_cluster_user.go @@ -45,7 +45,8 @@ func (r *ClusterUserResource) Metadata(ctx context.Context, req resource.Metadat func (r *ClusterUserResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "A database user in a RisingWave cluster.", + Description: "A cluster user is a database user that can connect to a cluster.", + MarkdownDescription: clusterUserMarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ MarkdownDescription: "The global identifier for the resource: [cluster ID].[username]", diff --git a/internal/provider/resource_privatelink.go b/internal/provider/resource_privatelink.go index 95c754b..da1a9d7 100644 --- a/internal/provider/resource_privatelink.go +++ b/internal/provider/resource_privatelink.go @@ -42,7 +42,8 @@ func (r *PrivateLinkResource) Metadata(ctx context.Context, req resource.Metadat func (r *PrivateLinkResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "A Private Link connection", + Description: "A Private Link connection on the RisingWave Cloud platform.", + MarkdownDescription: privateLinkMarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ MarkdownDescription: "The global identifier for the resource in format of UUID.",