Skip to content

Commit

Permalink
fix: support service name in cluster resources (#590)
Browse files Browse the repository at this point in the history
* fix: support service name in cluster resources

* fix: data source tag description
  • Loading branch information
wai-wong-edb authored Oct 8, 2024
1 parent 1f5717c commit 0ab00c2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/data-sources/biganimal_cluster/data-source.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@ output "service_account_ids" {
output "volume_snapshot_backup" {
value = coalesce(data.biganimal_cluster.this.post_gis, false)
}

output "service_name" {
value = data.biganimal_cluster.this.service_name
}
22 changes: 22 additions & 0 deletions pkg/provider/data_source_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,24 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq
"Pausing a high availability cluster shuts down all cluster nodes",
Optional: true,
},
"tags": schema.SetNestedAttribute{
Description: "Show existing tags associated with this resource",
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"tag_id": schema.StringAttribute{
Computed: true,
},
"tag_name": schema.StringAttribute{
Computed: true,
},
"color": schema.StringAttribute{
Computed: true,
},
},
},
},
"transparent_data_encryption": schema.SingleNestedAttribute{
MarkdownDescription: "Transparent Data Encryption (TDE) key",
Optional: true,
Expand Down Expand Up @@ -366,6 +384,10 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq
MarkdownDescription: "Transparent data encryption action.",
Computed: true,
},
"service_name": schema.StringAttribute{
MarkdownDescription: "Cluster connection service name.",
Computed: true,
},
},
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/provider/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ClusterResourceModel struct {
TransparentDataEncryptionAction types.String `tfsdk:"transparent_data_encryption_action"`
VolumeSnapshot types.Bool `tfsdk:"volume_snapshot_backup"`
Tags []commonTerraform.Tag `tfsdk:"tags"`
ServiceName types.String `tfsdk:"service_name"`

Timeouts timeouts.Value `tfsdk:"timeouts"`
}
Expand Down Expand Up @@ -569,6 +570,11 @@ func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest
Computed: true,
PlanModifiers: []planmodifier.String{plan_modifier.CustomTDEAction()},
},
"service_name": schema.StringAttribute{
MarkdownDescription: "Cluster connection service name.",
Computed: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
},
},
}
}
Expand Down Expand Up @@ -845,6 +851,7 @@ func readCluster(ctx context.Context, client *api.ClusterClient, tfClusterResour
tfClusterResource.ReadOnlyConnections = types.BoolPointerValue(responseCluster.ReadOnlyConnections)
tfClusterResource.ConnectionUri = types.StringPointerValue(&connection.PgUri)
tfClusterResource.RoConnectionUri = types.StringPointerValue(&connection.ReadOnlyPgUri)
tfClusterResource.ServiceName = types.StringPointerValue(&connection.ServiceName)
tfClusterResource.CspAuth = types.BoolPointerValue(responseCluster.CSPAuth)
tfClusterResource.LogsUrl = responseCluster.LogsUrl
tfClusterResource.MetricsUrl = responseCluster.MetricsUrl
Expand Down

0 comments on commit 0ab00c2

Please sign in to comment.