Skip to content

Commit

Permalink
feat: Read-only connection string for PGD
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalsawale9 committed Aug 12, 2024
1 parent 640ce40 commit 0b6e725
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/data-sources/pgd.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) PGD Cluster read-only connection URI. Only available for high availability clusters.

<a id="nestedatt--data_groups"></a>
### Nested Schema for `data_groups`
Expand Down Expand Up @@ -128,6 +133,7 @@ Read-Only:
- `resizing_pvc` (Set of String) Resizing PVC.
- `service_account_ids` (Set of String) A Google Cloud Service Account is used for logs. If you leave this blank, then you will be unable to access log details for this cluster. Required when cluster is deployed on BigAnimal's cloud account.
- `storage` (Attributes) Storage. (see [below for nested schema](#nestedatt--data_groups--storage))
- `read_only_connections` (Boolean) Is Read-only Connections/workloads enabled.

<a id="nestedatt--data_groups--allowed_ip_ranges"></a>
### Nested Schema for `data_groups.allowed_ip_ranges`
Expand Down
1 change: 1 addition & 0 deletions docs/resources/pgd.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,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`
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/biganimal_pgd/aws/data_group/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ resource "biganimal_pgd" "pgd_cluster" {
start_day = 6
start_time = "13:00"
}
read_only_connections = false

# pe_allowed_principal_ids = [
# <example_value> # ex: 123456789012
# ]
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/biganimal_pgd/azure/data_group/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ resource "biganimal_pgd" "pgd_cluster" {
start_day = 1
start_time = "13:00"
}
read_only_connections = false

# pe_allowed_principal_ids = [
# <example_value> # ex: "9334e5e6-7f47-aE61-5A4F-ee067daeEf4A"
# ]
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/biganimal_pgd/gcp/data_group/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ resource "biganimal_pgd" "pgd_cluster" {
start_day = 6
start_time = "13:00"
}
read_only_connections = false

# pe_allowed_principal_ids = [
# <example_value> # ex: "development-data-123456"
# ]
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/pgd/api/data_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ type DataGroup struct {
MaintenanceWindow *models.MaintenanceWindow `json:"maintenanceWindow,omitempty"`
ServiceAccountIds *[]string `json:"serviceAccountIds,omitempty"`
PeAllowedPrincipalIds *[]string `json:"peAllowedPrincipalIds,omitempty"`
RoConnectionUri *string `json:"roConnectionUri,omitempty"`
ReadOnlyConnections *bool `json:"readOnlyConnections,omitempty"`
}
2 changes: 2 additions & 0 deletions pkg/models/pgd/terraform/data_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ type DataGroup struct {
MaintenanceWindow *models.MaintenanceWindow `tfsdk:"maintenance_window"`
ServiceAccountIds types.Set `tfsdk:"service_account_ids"`
PeAllowedPrincipalIds types.Set `tfsdk:"pe_allowed_principal_ids"`
RoConnectionUri types.String `tfsdk:"ro_connection_uri"`
ReadOnlyConnections *bool `tfsdk:"read_only_connections"`
}
9 changes: 9 additions & 0 deletions pkg/provider/data_source_pgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ 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,
},
"read_only_connections": schema.BoolAttribute{
Description: "Is read-only connections enabled.",
Computed: true,
},
},
},
},
Expand Down
13 changes: 13 additions & 0 deletions pkg/provider/resource_pgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ func PgdSchema(ctx context.Context) schema.Schema {
},
},
},
"ro_connection_uri": schema.StringAttribute{
MarkdownDescription: "Cluster read-only connection URI.",
Computed: true,
PlanModifiers: []planmodifier.String{plan_modifier.CustomConnection()},
},
"instance_type": schema.SingleNestedAttribute{
Description: "Instance type.",
Required: true,
Expand Down Expand Up @@ -376,6 +381,11 @@ func PgdSchema(ctx context.Context) schema.Schema {
ElementType: types.StringType,
PlanModifiers: []planmodifier.Set{setplanmodifier.UseStateForUnknown()},
},
"read_only_connections": schema.BoolAttribute{
Description: "Is read-only connections enabled.",
Optional: true,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -659,6 +669,7 @@ func (p pgdResource) Create(ctx context.Context, req resource.CreateRequest, res
Storage: storage,
ServiceAccountIds: svAccIds,
PeAllowedPrincipalIds: principalIds,
ReadOnlyConnections: v.ReadOnlyConnections,
}
*clusterReqBody.Groups = append(*clusterReqBody.Groups, apiDGModel)
}
Expand Down Expand Up @@ -1368,6 +1379,8 @@ func buildTFGroupsAs(ctx context.Context, diags *diag.Diagnostics, state tfsdk.S
MaintenanceWindow: apiDgModel.MaintenanceWindow,
ServiceAccountIds: types.SetValueMust(types.StringType, serviceAccIds),
PeAllowedPrincipalIds: types.SetValueMust(types.StringType, principalIds),
RoConnectionUri: types.StringPointerValue(apiDgModel.RoConnectionUri),
ReadOnlyConnections: apiDgModel.ReadOnlyConnections,
}

outPgdTFResource.DataGroups = append(outPgdTFResource.DataGroups, tfDGModel)
Expand Down

0 comments on commit 0b6e725

Please sign in to comment.