Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Read-only connection string for PGD
Browse files Browse the repository at this point in the history
vishalsawale9 committed Aug 5, 2024

Unverified

We had a problem verifying this signature. Please try again later.
1 parent ece83ea commit 36c6432
Showing 8 changed files with 47 additions and 10 deletions.
5 changes: 5 additions & 0 deletions docs/data-sources/pgd.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,10 @@ output "data_groups" {
output "witness_groups" {
value = data.biganimal_pgd.this.witness_groups
}
output "ro_connection_uri" {
value = data.biganimal_cluster.this.ro_connection_uri
}
```

## PGD Data Source Example
@@ -98,6 +102,7 @@ terraform {
- `data_groups` (Attributes Set) Cluster data groups. (see [below for nested schema](#nestedatt--data_groups))
- `id` (String) The ID of this resource.
- `witness_groups` (Attributes Set) (see [below for nested schema](#nestedatt--witness_groups))
- `ro_connection_uri` (String) Cluster read-only connection URI. Only available for high availability clusters.

<a id="nestedatt--data_groups"></a>
### Nested Schema for `data_groups`
5 changes: 5 additions & 0 deletions docs/resources/pgd.md
Original file line number Diff line number Diff line change
@@ -94,6 +94,10 @@ resource "biganimal_pgd" "pgd_cluster" {
start_day = 1
start_time = "13:00"
}
ro_connection_uri = {
value = resource.biganimal_cluster.ha_cluster.ro_connection_uri
}
},
]
}
@@ -1714,6 +1718,7 @@ Read-Only:
- `metrics_url` (String) The URL to find the metrics of this cluster.
- `phase` (String) Current phase of the data group.
- `resizing_pvc` (Set of String) Resizing PVC.
- `ro_connection_uri` (String) Cluster read-only connection URI. Only available for high availability clusters.

<a id="nestedatt--data_groups--cloud_provider"></a>
### Nested Schema for `data_groups.cloud_provider`
4 changes: 4 additions & 0 deletions examples/data-sources/biganimal_pgd/data-source.tf
Original file line number Diff line number Diff line change
@@ -28,3 +28,7 @@ output "data_groups" {
output "witness_groups" {
value = data.biganimal_pgd.this.witness_groups
}

output "ro_connection_uri" {
value = data.biganimal_pgd.this.ro_connection_uri
}
4 changes: 4 additions & 0 deletions examples/resources/biganimal_pgd/aws/data_group/resource.tf
Original file line number Diff line number Diff line change
@@ -97,3 +97,7 @@ output "password" {
sensitive = true
value = resource.biganimal_pgd.pgd_cluster.password
}

output "ro_connection_uri" {
value = resource.biganimal_cluster.ha_cluster.ro_connection_uri
}
4 changes: 4 additions & 0 deletions examples/resources/biganimal_pgd/azure/data_group/resource.tf
Original file line number Diff line number Diff line change
@@ -97,3 +97,7 @@ output "password" {
sensitive = true
value = resource.biganimal_pgd.pgd_cluster.password
}

output "ro_connection_uri" {
value = resource.biganimal_cluster.ha_cluster.ro_connection_uri
}
4 changes: 4 additions & 0 deletions examples/resources/biganimal_pgd/gcp/data_group/resource.tf
Original file line number Diff line number Diff line change
@@ -101,3 +101,7 @@ output "password" {
sensitive = true
value = resource.biganimal_pgd.pgd_cluster.password
}

output "ro_connection_uri" {
value = resource.biganimal_cluster.ha_cluster.ro_connection_uri
}
5 changes: 5 additions & 0 deletions pkg/provider/data_source_pgd.go
Original file line number Diff line number Diff line change
@@ -275,6 +275,11 @@ func (p pgdDataSource) Schema(ctx context.Context, req datasource.SchemaRequest,
Computed: true,
ElementType: types.StringType,
},
"ro_connection_uri": schema.SetAttribute{
Description: "Read-only connection URI.",
Computed: true,
ElementType: types.StringType,
},
},
},
},
26 changes: 16 additions & 10 deletions pkg/provider/resource_pgd.go
Original file line number Diff line number Diff line change
@@ -331,6 +331,11 @@ func PgdSchema(ctx context.Context) schema.Schema {
},
},
},
"ro_connection_uri": schema.StringAttribute{
MarkdownDescription: "Cluster read-only connection URI. Only available for high availability clusters.",
Computed: true,
PlanModifiers: []planmodifier.String{plan_modifier.CustomConnection()},
},
"instance_type": schema.SingleNestedAttribute{
Description: "Instance type.",
Required: true,
@@ -588,16 +593,17 @@ func (p *pgdResource) Configure(_ context.Context, req resource.ConfigureRequest
}

type PGD struct {
ID *string `tfsdk:"id"`
ProjectId string `tfsdk:"project_id"`
ClusterId *string `tfsdk:"cluster_id"`
ClusterName *string `tfsdk:"cluster_name"`
MostRecent *bool `tfsdk:"most_recent"`
Password *string `tfsdk:"password"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
Pause types.Bool `tfsdk:"pause"`
DataGroups []terraform.DataGroup `tfsdk:"data_groups"`
WitnessGroups []terraform.WitnessGroup `tfsdk:"witness_groups"`
ID *string `tfsdk:"id"`
ProjectId string `tfsdk:"project_id"`
ClusterId *string `tfsdk:"cluster_id"`
ClusterName *string `tfsdk:"cluster_name"`
MostRecent *bool `tfsdk:"most_recent"`
Password *string `tfsdk:"password"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
Pause types.Bool `tfsdk:"pause"`
DataGroups []terraform.DataGroup `tfsdk:"data_groups"`
WitnessGroups []terraform.WitnessGroup `tfsdk:"witness_groups"`
RoConnectionUri types.String `tfsdk:"ro_connection_uri"`
}

// Create creates the resource and sets the initial Terraform state.

0 comments on commit 36c6432

Please sign in to comment.