From 0a1c9bce1f45a098cc84177cb464421902304c9f Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 12:32:36 +0700 Subject: [PATCH 1/7] Update instellar-go lib --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b9d7295..76c6980 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/hashicorp/terraform-plugin-go v0.22.1 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-testing v1.7.0 - github.com/upmaru/instellar-go v0.6.4 + github.com/upmaru/instellar-go v0.7.0 ) require ( diff --git a/go.sum b/go.sum index da8cb9e..0e6e73a 100644 --- a/go.sum +++ b/go.sum @@ -164,8 +164,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/upmaru/instellar-go v0.6.4 h1:adPEvkJ5TRsOAehDJ9ZSqFoW38WjhNfvSR0kJChSqvc= -github.com/upmaru/instellar-go v0.6.4/go.mod h1:DyU7Pd7Syn6NIbdD5PMGkR1XE+qxGj0UDYwoKZgUxyI= +github.com/upmaru/instellar-go v0.7.0 h1:59rqKs/Ffctu0h9Cx+9Yr6j1SeoaYy+fiS5BsIwzI98= +github.com/upmaru/instellar-go v0.7.0/go.mod h1:DyU7Pd7Syn6NIbdD5PMGkR1XE+qxGj0UDYwoKZgUxyI= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= From 5809bc99803466d42694a993c0cb27a2ee2742c7 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 15:14:03 +0700 Subject: [PATCH 2/7] Setup balancer resource --- go.mod | 2 +- go.sum | 4 +- instellar/balancer/resource.go | 167 +++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 instellar/balancer/resource.go diff --git a/go.mod b/go.mod index 76c6980..99731fc 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/hashicorp/terraform-plugin-go v0.22.1 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-testing v1.7.0 - github.com/upmaru/instellar-go v0.7.0 + github.com/upmaru/instellar-go v0.7.1 ) require ( diff --git a/go.sum b/go.sum index 0e6e73a..e6da7ff 100644 --- a/go.sum +++ b/go.sum @@ -164,8 +164,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/upmaru/instellar-go v0.7.0 h1:59rqKs/Ffctu0h9Cx+9Yr6j1SeoaYy+fiS5BsIwzI98= -github.com/upmaru/instellar-go v0.7.0/go.mod h1:DyU7Pd7Syn6NIbdD5PMGkR1XE+qxGj0UDYwoKZgUxyI= +github.com/upmaru/instellar-go v0.7.1 h1:yMslk+H9uNrzFLflw7ISSX/QkltOaiWIEL6jmIjzmrY= +github.com/upmaru/instellar-go v0.7.1/go.mod h1:DyU7Pd7Syn6NIbdD5PMGkR1XE+qxGj0UDYwoKZgUxyI= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= diff --git a/instellar/balancer/resource.go b/instellar/balancer/resource.go new file mode 100644 index 0000000..4a6b371 --- /dev/null +++ b/instellar/balancer/resource.go @@ -0,0 +1,167 @@ +package balancer + +import ( + "context" + "fmt" + "strconv" + "time" + + // instellar client = instc. + instc "github.com/upmaru/instellar-go" + + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var ( + _ resource.Resource = &balancerResource{} + _ resource.ResourceWithConfigure = &balancerResource{} + _ resource.ResourceWithImportState = &balancerResource{} +) + +func NewBalancerResource() resource.Resource { + return &balancerResource{} +} + +type balancerResource struct { + client *instc.Client +} + +type balancerResourceModel struct { + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Address types.String `tfsdk:"address"` + CurrentState types.String `tfsdk:"current_state"` + ClusterID types.String `tfsdk:"cluster_id"` + LastUpdated types.String `tfsdk:"last_updated"` +} + +func (r *balancerResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_balancer" +} + +func (r *balancerResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Balancer is what instellar use to balance the load of the incoming requests to the instellar components.", + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "Balancer identifier", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "name": schema.StringAttribute{ + Description: "Balancer Name", + Required: true, + }, + "address": schema.StringAttribute{ + Description: "Balancer Address", + Required: true, + }, + "current_state": schema.StringAttribute{ + Description: "Balancer Current State", + Computed: true, + }, + "cluster_id": schema.StringAttribute{ + Description: "Which cluster does balancer belong to", + Required: true, + }, + "last_updated": schema.StringAttribute{ + Description: "Balancer Last Updated", + Computed: true, + }, + }, + } +} + +func (r *balancerResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*instc.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf( + "Expected *instc.Client, got: %T. Please report this issue to the provider developers.", + req.ProviderData, + ), + ) + return + } + + r.client = client +} + +func (r *balancerResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan balancerResourceModel + diags := req.Plan.Get(ctx, &plan) + + resp.Diagnostics.Append(diags...) + + if resp.Diagnostics.HasError() { + return + } + + balancerParams := instc.BalancerParams{ + Name: plan.Name.ValueString(), + Address: plan.Address.ValueString(), + } + + balancer, err := r.client.CreateBalancer(plan.ClusterID.ValueString(), balancerParams) + + if err != nil { + resp.Diagnostics.AddError( + "Failed to create balancer", + "Could not create balancer, unexpected error: "+err.Error(), + ) + return + } + + plan.ID = types.StringValue(strconv.Itoa(balancer.Data.Attributes.ID)) + plan.CurrentState = types.StringValue(balancer.Data.Attributes.CurrentState) + plan.ClusterID = types.StringValue(strconv.Itoa(balancer.Data.Attributes.ClusterID)) + plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850)) + + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + + if resp.Diagnostics.HasError() { + return + } +} + +func (r *balancerResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state balancerResourceModel + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + balancer, err := r.client.GetBalancer(state.ID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error reading uplink", + "Could not read uplink id "+state.ID.ValueString()+": "+err.Error(), + ) + } + + state.Name = types.StringValue(balancer.Data.Attributes.Name) + state.Address = types.StringValue(balancer.Data.Attributes.Address) + state.CurrentState = types.StringValue(balancer.Data.Attributes.CurrentState) + state.ClusterID = types.StringValue(strconv.Itoa(balancer.Data.Attributes.ClusterID)) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} \ No newline at end of file From b37261050bc885afa8736dd12da23364ba7ccdcc Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 16:15:47 +0700 Subject: [PATCH 3/7] Add test for balancer resource --- instellar/balancer/resource.go | 68 +++++++++++++++++++++++++++++ instellar/balancer/resource_test.go | 59 +++++++++++++++++++++++++ instellar/provider.go | 2 + 3 files changed, 129 insertions(+) create mode 100644 instellar/balancer/resource_test.go diff --git a/instellar/balancer/resource.go b/instellar/balancer/resource.go index 4a6b371..433e17c 100644 --- a/instellar/balancer/resource.go +++ b/instellar/balancer/resource.go @@ -164,4 +164,72 @@ func (r *balancerResource) Read(ctx context.Context, req resource.ReadRequest, r if resp.Diagnostics.HasError() { return } +} + +func (r *balancerResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan balancerResourceModel + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + balancerParams := instc.BalancerParams{ + Name: plan.Name.ValueString(), + Address: plan.Address.ValueString(), + } + + _, err := r.client.UpdateBalancer(plan.ID.ValueString(), balancerParams) + + if err != nil { + resp.Diagnostics.AddError( + "Error updating balancer", + "Could not update balancer, unexpected error: "+err.Error(), + ) + return + } + + balancer, err := r.client.GetBalancer(plan.ID.ValueString()) + + if err != nil { + resp.Diagnostics.AddError( + "Error reading balancer", + "Could not read balancer ID "+plan.ID.ValueString()+": "+err.Error(), + ) + return + } + + plan.Name = types.StringValue(balancer.Data.Attributes.Name) + plan.Address = types.StringValue(balancer.Data.Attributes.Address) + plan.CurrentState = types.StringValue(balancer.Data.Attributes.CurrentState) + plan.ClusterID = types.StringValue(strconv.Itoa(balancer.Data.Attributes.ClusterID)) + plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850)) + + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *balancerResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state *balancerResourceModel + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + _, err := r.client.DeleteBalancer(state.ID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error deleting balancer", + "Cloud not delete balancer, unexpected error: "+err.Error(), + ) + return + } +} + +func (r *balancerResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } \ No newline at end of file diff --git a/instellar/balancer/resource_test.go b/instellar/balancer/resource_test.go new file mode 100644 index 0000000..3000292 --- /dev/null +++ b/instellar/balancer/resource_test.go @@ -0,0 +1,59 @@ +package balancer_test + +import ( + "fmt" + "strings" + "testing" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/upmaru/terraform-provider-instellar/internal/acceptance" +) + +func TestAccBalancerResource(t *testing.T) { + clusterUUID := uuid.New() + clusterNameSegments := strings.Split(clusterUUID.String(), "-") + clusterNameSlug := strings.Join([]string{clusterNameSegments[0], clusterNameSegments[1]}, "-") + + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: acceptance.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: buildConfig(clusterNameSlug), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("instellar_balancer.test", "name", "test-balancer"), + resource.TestCheckResourceAttr("instellar_balancer.test", "address", "some.address.com"), + // Verify computed attribute fields. + resource.TestCheckResourceAttr("instellar_balancer.test", "current_state", "active"), + // Dynamic values + resource.TestCheckResourceAttrSet("instellar_balancer.test", "id"), + resource.TestCheckResourceAttrSet("instellar_balancer.test", "last_updated"), + ), + }, + { + ResourceName: "instellar_balancer.test", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"last_updated", "current_state"}, + }, + }, + }) +} + +func buildConfig(clusterName string) string { + return acceptance.ProviderConfig + fmt.Sprintf(` + resource "instellar_cluster" "test" { + name = "%s" + provider_name = "aws" + region = "ap-southeast-1" + endpoint = "127.0.0.1:8443" + password_token = "some-password-or-token" + } + + resource "instellar_balancer" "test" { + name = "test-balancer" + address = "some.address.com" + cluster_id = instellar_cluster.test.id + } + `, clusterName) +} \ No newline at end of file diff --git a/instellar/provider.go b/instellar/provider.go index 6d99008..174e3a8 100644 --- a/instellar/provider.go +++ b/instellar/provider.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/upmaru/terraform-provider-instellar/instellar/balancer" "github.com/upmaru/terraform-provider-instellar/instellar/cluster" "github.com/upmaru/terraform-provider-instellar/instellar/component" "github.com/upmaru/terraform-provider-instellar/instellar/node" @@ -144,6 +145,7 @@ func (p *instellarProvider) Resources(_ context.Context) []func() resource.Resou return []func() resource.Resource{ cluster.NewClusterResource, uplink.NewUplinkResource, + balancer.NewBalancerResource, node.NewNodeResource, storage.NewStorageResource, component.NewComponentResource, From d8604ea3f1790e4e4f611f677faf0565a52ef347 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 16:17:07 +0700 Subject: [PATCH 4/7] Clean up formatting and update documentation --- docs/resources/balancer.md | 28 ++++++++++++++++++++++++++++ instellar/balancer/resource.go | 24 ++++++++++++------------ instellar/balancer/resource_test.go | 2 +- 3 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 docs/resources/balancer.md diff --git a/docs/resources/balancer.md b/docs/resources/balancer.md new file mode 100644 index 0000000..a19c93a --- /dev/null +++ b/docs/resources/balancer.md @@ -0,0 +1,28 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "instellar_balancer Resource - terraform-provider-instellar" +subcategory: "" +description: |- + Balancer is what instellar use to balance the load of the incoming requests to the instellar components. +--- + +# instellar_balancer (Resource) + +Balancer is what instellar use to balance the load of the incoming requests to the instellar components. + + + + +## Schema + +### Required + +- `address` (String) Balancer Address +- `cluster_id` (String) Which cluster does balancer belong to +- `name` (String) Balancer Name + +### Read-Only + +- `current_state` (String) Balancer Current State +- `id` (String) Balancer identifier +- `last_updated` (String) Balancer Last Updated diff --git a/instellar/balancer/resource.go b/instellar/balancer/resource.go index 433e17c..642d0af 100644 --- a/instellar/balancer/resource.go +++ b/instellar/balancer/resource.go @@ -18,8 +18,8 @@ import ( ) var ( - _ resource.Resource = &balancerResource{} - _ resource.ResourceWithConfigure = &balancerResource{} + _ resource.Resource = &balancerResource{} + _ resource.ResourceWithConfigure = &balancerResource{} _ resource.ResourceWithImportState = &balancerResource{} ) @@ -32,12 +32,12 @@ type balancerResource struct { } type balancerResourceModel struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Address types.String `tfsdk:"address"` - CurrentState types.String `tfsdk:"current_state"` - ClusterID types.String `tfsdk:"cluster_id"` - LastUpdated types.String `tfsdk:"last_updated"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Address types.String `tfsdk:"address"` + CurrentState types.String `tfsdk:"current_state"` + ClusterID types.String `tfsdk:"cluster_id"` + LastUpdated types.String `tfsdk:"last_updated"` } func (r *balancerResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -111,7 +111,7 @@ func (r *balancerResource) Create(ctx context.Context, req resource.CreateReques } balancerParams := instc.BalancerParams{ - Name: plan.Name.ValueString(), + Name: plan.Name.ValueString(), Address: plan.Address.ValueString(), } @@ -119,7 +119,7 @@ func (r *balancerResource) Create(ctx context.Context, req resource.CreateReques if err != nil { resp.Diagnostics.AddError( - "Failed to create balancer", + "Failed to create balancer", "Could not create balancer, unexpected error: "+err.Error(), ) return @@ -175,7 +175,7 @@ func (r *balancerResource) Update(ctx context.Context, req resource.UpdateReques } balancerParams := instc.BalancerParams{ - Name: plan.Name.ValueString(), + Name: plan.Name.ValueString(), Address: plan.Address.ValueString(), } @@ -232,4 +232,4 @@ func (r *balancerResource) Delete(ctx context.Context, req resource.DeleteReques func (r *balancerResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} \ No newline at end of file +} diff --git a/instellar/balancer/resource_test.go b/instellar/balancer/resource_test.go index 3000292..519b286 100644 --- a/instellar/balancer/resource_test.go +++ b/instellar/balancer/resource_test.go @@ -56,4 +56,4 @@ func buildConfig(clusterName string) string { cluster_id = instellar_cluster.test.id } `, clusterName) -} \ No newline at end of file +} From 0ad81698e5b4cd7a5434baa28bba7a3752bd531d Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 16:20:07 +0700 Subject: [PATCH 5/7] Update plugin framework --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 99731fc..89d109b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/google/uuid v1.6.0 github.com/hashicorp/terraform-plugin-docs v0.18.0 - github.com/hashicorp/terraform-plugin-framework v1.6.1 + github.com/hashicorp/terraform-plugin-framework v1.7.0 github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 github.com/hashicorp/terraform-plugin-go v0.22.1 github.com/hashicorp/terraform-plugin-log v0.9.0 diff --git a/go.sum b/go.sum index e6da7ff..41380a0 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,8 @@ github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRy github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= github.com/hashicorp/terraform-plugin-docs v0.18.0 h1:2bINhzXc+yDeAcafurshCrIjtdu1XHn9zZ3ISuEhgpk= github.com/hashicorp/terraform-plugin-docs v0.18.0/go.mod h1:iIUfaJpdUmpi+rI42Kgq+63jAjI8aZVTyxp3Bvk9Hg8= -github.com/hashicorp/terraform-plugin-framework v1.6.1 h1:hw2XrmUu8d8jVL52ekxim2IqDc+2Kpekn21xZANARLU= -github.com/hashicorp/terraform-plugin-framework v1.6.1/go.mod h1:aJI+n/hBPhz1J+77GdgNfk5svW12y7fmtxe/5L5IuwI= +github.com/hashicorp/terraform-plugin-framework v1.7.0 h1:wOULbVmfONnJo9iq7/q+iBOBJul5vRovaYJIu2cY/Pw= +github.com/hashicorp/terraform-plugin-framework v1.7.0/go.mod h1:jY9Id+3KbZ17OMpulgnWLSfwxNVYSoYBQFTgsx044CI= github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= github.com/hashicorp/terraform-plugin-go v0.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w= From 397d2702ba8f3ec471a730ad5a2d1ef958c9e309 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 16:25:16 +0700 Subject: [PATCH 6/7] Add example for balancer resource --- examples/provider/provider.tf | 2 +- examples/resources/instellar_balancer/resource.tf | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 examples/resources/instellar_balancer/resource.tf diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 45ad634..adc0ab1 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,4 +1,4 @@ provider "instellar" { - host = "https://web.instellar.app" + host = "https://opsmaru.com" auth_token = "your-instellar-auth-token" } diff --git a/examples/resources/instellar_balancer/resource.tf b/examples/resources/instellar_balancer/resource.tf new file mode 100644 index 0000000..0905e14 --- /dev/null +++ b/examples/resources/instellar_balancer/resource.tf @@ -0,0 +1,13 @@ +resource "instellar_cluster" "main" { + name = "some-unique-cluster-name" + provider_name = "aws" + region = "ap-southeast-1" + endpoint = "127.0.0.1:8443" + password_token = "some-password-or-token" +} + +resource "instellar_balancer" "this" { + name = "some-balancer" + address = "some.example.com" + cluster_id = instellar_cluster.main.id +} \ No newline at end of file From 1659be8150905157bb8f2916f9284e1609907273 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Fri, 22 Mar 2024 16:29:06 +0700 Subject: [PATCH 7/7] Update docs --- docs/index.md | 2 +- docs/resources/balancer.md | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index c069eb8..6bcdb01 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,7 +14,7 @@ Provision instellar resources. ```terraform provider "instellar" { - host = "https://web.instellar.app" + host = "https://opsmaru.com" auth_token = "your-instellar-auth-token" } ``` diff --git a/docs/resources/balancer.md b/docs/resources/balancer.md index a19c93a..ae9d5ba 100644 --- a/docs/resources/balancer.md +++ b/docs/resources/balancer.md @@ -10,7 +10,23 @@ description: |- Balancer is what instellar use to balance the load of the incoming requests to the instellar components. - +## Example Usage + +```terraform +resource "instellar_cluster" "main" { + name = "some-unique-cluster-name" + provider_name = "aws" + region = "ap-southeast-1" + endpoint = "127.0.0.1:8443" + password_token = "some-password-or-token" +} + +resource "instellar_balancer" "this" { + name = "some-balancer" + address = "some.example.com" + cluster_id = instellar_cluster.main.id +} +``` ## Schema