Skip to content

Commit

Permalink
feat: support serverless plan (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Liang Huang <sammy.huang@zilliz.com>
  • Loading branch information
samhuang-z committed May 24, 2024
1 parent 7e2f3d0 commit 85dba37
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
11 changes: 10 additions & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ data "zillizcloud_project" "default" {
resource "zillizcloud_cluster" "free_plan_cluster" {
# Defining a basic starter cluster
cluster_name = "Cluster-01" # The name of the cluster
plan = "Free" # The service plan for the cluster The name of the cluster
project_id = data.zillizcloud_project.default.id # Linking to the project ID fetched earlier
}
resource "zillizcloud_cluster" "standard_plan_cluster" {
resource "zillizcloud_cluster" "serverless_plan_cluster" {
# Defining a basic starter cluster
cluster_name = "Cluster-02" # The name of the cluster
plan = "Serverless" # The service plan for the cluster# The name of the cluster
project_id = data.zillizcloud_project.default.id # Linking to the project ID fetched earlier
}
resource "zillizcloud_cluster" "standard_plan_cluster" {
cluster_name = "Cluster-03" # The name of the cluster
region_id = "aws-us-east-2" # The region where the cluster will be deployed
plan = "Standard" # The service plan for the cluster
cu_size = "1" # The size of the compute unit
Expand Down
12 changes: 10 additions & 2 deletions examples/resources/zillizcloud_cluster/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ data "zillizcloud_project" "default" {
resource "zillizcloud_cluster" "free_plan_cluster" {
# Defining a basic starter cluster
cluster_name = "Cluster-01" # The name of the cluster
plan = "Free" # The service plan for the cluster The name of the cluster
project_id = data.zillizcloud_project.default.id # Linking to the project ID fetched earlier
}

resource "zillizcloud_cluster" "standard_plan_cluster" {
resource "zillizcloud_cluster" "serverless_plan_cluster" {
# Defining a basic starter cluster
cluster_name = "Cluster-02" # The name of the cluster
plan = "Serverless" # The service plan for the cluster# The name of the cluster
project_id = data.zillizcloud_project.default.id # Linking to the project ID fetched earlier
}


resource "zillizcloud_cluster" "standard_plan_cluster" {
cluster_name = "Cluster-03" # The name of the cluster
region_id = "aws-us-east-2" # The region where the cluster will be deployed
plan = "Standard" # The service plan for the cluster
cu_size = "1" # The size of the compute unit
cu_type = "Performance-optimized" # The type of compute unit, optimized for performance
project_id = data.zillizcloud_project.default.id # Linking to the project ID fetched earlier
}

16 changes: 8 additions & 8 deletions internal/provider/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func (r *ClusterResource) Schema(ctx context.Context, req resource.SchemaRequest
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Validators: []validator.String{
stringvalidator.AlsoRequires(
path.MatchRelative().AtParent().AtName("cu_size"),
path.MatchRelative().AtParent().AtName("cu_type"),
),
},
// Validators: []validator.String{
// stringvalidator.AlsoRequires(
// path.MatchRelative().AtParent().AtName("cu_size"),
// path.MatchRelative().AtParent().AtName("cu_type"),
// ),
// },
},
"cu_size": schema.Int64Attribute{
MarkdownDescription: "The size of the CU to be used for the created cluster. It is an integer from 1 to 256.",
Expand Down Expand Up @@ -249,10 +249,10 @@ func (r *ClusterResource) Create(ctx context.Context, req resource.CreateRequest
return
}

if (data.Plan.IsNull() || zilliz.Plan(data.Plan.ValueString()) == zilliz.FreePlan) && data.CuSize.IsUnknown() && data.CuType.IsNull() {
if (data.Plan.IsNull() || zilliz.Plan(data.Plan.ValueString()) == zilliz.FreePlan || zilliz.Plan(data.Plan.ValueString()) == zilliz.ServerlessPlan) && data.CuSize.IsUnknown() && data.CuType.IsNull() {

response, err = client.CreateServerlessCluster(zilliz.CreateServerlessClusterParams{
// Plan: zilliz.Plan(data.Plan.ValueString()),
Plan: zilliz.Plan(data.Plan.ValueString()),
ClusterName: data.ClusterName.ValueString(),
ProjectId: data.ProjectId.ValueString(),
})
Expand Down

0 comments on commit 85dba37

Please sign in to comment.