Skip to content

Commit

Permalink
adds description for tembo_instance fields & validation (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahadarsh authored Sep 21, 2023
1 parent 6584eb7 commit 7d1380e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 38 deletions.
30 changes: 15 additions & 15 deletions docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,27 @@ output "instance" {

### Required

- `cpu` (String)
- `environment` (String)
- `instance_name` (String)
- `memory` (String)
- `org_id` (String)
- `stack_type` (String)
- `storage` (String)
- `cpu` (String) CPU. Supported values: 1, 2, 4, 8, 16, 32
- `environment` (String) Environment. Values supported: dev, test, prod
- `instance_name` (String) Unique name of the instance
- `memory` (String) Memory. Values supported: 1Gi, 2Gi, 4Gi, 8Gi, 16Gi, 32Gi
- `org_id` (String) Id of the organization in which the instance will be created
- `stack_type` (String) Stack type for the instance. Supported values: Standard, MessageQueue, MachineLearning, OLAP, OLTP
- `storage` (String) Storage. Values supported: 10Gi, 50Gi, 100Gi, 200Gi, 300Gi, 400Gi, 500Gi

### Optional

- `extensions` (Attributes List) (see [below for nested schema](#nestedatt--extensions))
- `extra_domains_rw` (List of String)
- `postgres_configs` (Attributes List) (see [below for nested schema](#nestedatt--postgres_configs))
- `replicas` (Number)
- `trunk_installs` (Attributes List) (see [below for nested schema](#nestedatt--trunk_installs))
- `extensions` (Attributes List) Extensions to install in the instance (see [below for nested schema](#nestedatt--extensions))
- `extra_domains_rw` (List of String) Custom domain. Read more [here](https://tembo.io/docs/tembo-cloud/custom-domains/)
- `postgres_configs` (Attributes List) Postgres config values (see [below for nested schema](#nestedatt--postgres_configs))
- `replicas` (Number) Instance replicas
- `trunk_installs` (Attributes List) Trunk installs (see [below for nested schema](#nestedatt--trunk_installs))

### Read-Only

- `instance_id` (String)
- `last_updated` (String)
- `state` (String)
- `instance_id` (String) Unique ID for the instance generated by Tembo
- `last_updated` (String) Last updated date time in UTC
- `state` (String) Instance state. Values: Submitted, Up, Configuring, Error, Restarting, Starting, Stopping, Stopped, Deleting, Deleted

<a id="nestedatt--extensions"></a>
### Nested Schema for `extensions`
Expand Down
61 changes: 38 additions & 23 deletions internal/provider/cluster_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,60 +127,73 @@ func (r *temboInstanceResource) Schema(_ context.Context, _ resource.SchemaReque
Description: "Resource for creating a tembo instance.",
Attributes: map[string]schema.Attribute{
"instance_id": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Unique ID for the instance generated by Tembo",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"last_updated": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Last updated date time in UTC",
Computed: true,
},
"instance_name": schema.StringAttribute{
Required: true,
MarkdownDescription: "Unique name of the instance",
Required: true,
Validators: []validator.String{
stringvalidator.LengthAtMost(20),
},
},
"org_id": schema.StringAttribute{
Required: true,
MarkdownDescription: "Id of the organization in which the instance will be created",
Required: true,
},
"cpu": schema.StringAttribute{
Required: true,
Validators: []validator.String{stringvalidator.OneOf(cpuOptions...)},
MarkdownDescription: "CPU. Supported values: 1, 2, 4, 8, 16, 32",
Required: true,
Validators: []validator.String{stringvalidator.OneOf(cpuOptions...)},
},
"stack_type": schema.StringAttribute{
Required: true,
Validators: []validator.String{stringvalidator.OneOf(stackOptions...)},
MarkdownDescription: "Stack type for the instance. Supported values: Standard, MessageQueue, MachineLearning, OLAP, OLTP",
Required: true,
Validators: []validator.String{stringvalidator.OneOf(stackOptions...)},
},
"replicas": schema.Int64Attribute{
Optional: true,
Computed: true,
Default: int64default.StaticInt64(DefaultReplicas),
MarkdownDescription: "Instance replicas",
Optional: true,
Computed: true,
Default: int64default.StaticInt64(DefaultReplicas),
},
"environment": schema.StringAttribute{
Required: true,
Validators: []validator.String{stringvalidator.OneOf(envOptions...)},
MarkdownDescription: "Environment. Values supported: dev, test, prod",
Required: true,
Validators: []validator.String{stringvalidator.OneOf(envOptions...)},
},
"memory": schema.StringAttribute{
Required: true,
Validators: []validator.String{stringvalidator.OneOf(memoryOptions...)},
MarkdownDescription: "Memory. Values supported: 1Gi, 2Gi, 4Gi, 8Gi, 16Gi, 32Gi",
Required: true,
Validators: []validator.String{stringvalidator.OneOf(memoryOptions...)},
},
"storage": schema.StringAttribute{
Required: true,
Validators: []validator.String{stringvalidator.OneOf(storageOptions...)},
MarkdownDescription: "Storage. Values supported: 10Gi, 50Gi, 100Gi, 200Gi, 300Gi, 400Gi, 500Gi",
Required: true,
Validators: []validator.String{stringvalidator.OneOf(storageOptions...)},
},
"state": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Instance state. Values: Submitted, Up, Configuring, Error, Restarting, Starting, Stopping, Stopped, Deleting, Deleted",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"extra_domains_rw": schema.ListAttribute{
Optional: true,
ElementType: types.StringType,
MarkdownDescription: "Custom domain. Read more [here](https://tembo.io/docs/tembo-cloud/custom-domains/)",
Optional: true,
ElementType: types.StringType,
},
"postgres_configs": schema.ListNestedAttribute{
Optional: true,
MarkdownDescription: "Postgres config values",
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Expand All @@ -193,7 +206,8 @@ func (r *temboInstanceResource) Schema(_ context.Context, _ resource.SchemaReque
},
},
"trunk_installs": schema.ListNestedAttribute{
Optional: true,
MarkdownDescription: "Trunk installs",
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Expand All @@ -206,7 +220,8 @@ func (r *temboInstanceResource) Schema(_ context.Context, _ resource.SchemaReque
},
},
"extensions": schema.ListNestedAttribute{
Optional: true,
MarkdownDescription: "Extensions to install in the instance",
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Expand Down

0 comments on commit 7d1380e

Please sign in to comment.