Skip to content

Commit

Permalink
Add docs and remove FF for DB Audit logging (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddarth-Baldwa authored Dec 19, 2024
1 parent 17af3d7 commit 7c17d25
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 18 deletions.
57 changes: 57 additions & 0 deletions docs/data-sources/db_audit_logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ybm_db_audit_logging Data Source - ybm"
subcategory: ""
description: |-
The data source to fetch DB Audit log configuration for a cluster given cluster ID in YugabyteDB Aeon.
---

# ybm_db_audit_logging (Data Source)

The data source to fetch DB Audit log configuration for a cluster given cluster ID in YugabyteDB Aeon.

## Example Usage

```terraform
data "ybm_db_audit_logging" "example_db_audit_log_config" {
cluster_id = "<cluster-id>"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cluster_id` (String) ID of the cluster from which DB Audit Logs will be exported

### Read-Only

- `account_id` (String) ID of the account this DB Audit log configuration belongs to.
- `cluster_name` (String) Name of the cluster from which DB Audit Logs will be exported
- `config_id` (String) ID of the DB Audit log configuration
- `integration_id` (String) ID of the integration to which the DB Audit Logs will be exported
- `integration_name` (String) Name of the integration to which the DB Audit Logs will be exported
- `project_id` (String) ID of the project this DB Audit log configuration belongs to.
- `state` (String) The status of DB Audit Logging on the cluster
- `ysql_config` (Attributes) The specification for a DB Audit ysql export configuration (see [below for nested schema](#nestedatt--ysql_config))

<a id="nestedatt--ysql_config"></a>
### Nested Schema for `ysql_config`

Read-Only:

- `log_settings` (Attributes) Db Audit Ysql Log Settings (see [below for nested schema](#nestedatt--ysql_config--log_settings))
- `statement_classes` (Set of String) List of ysql statements

<a id="nestedatt--ysql_config--log_settings"></a>
### Nested Schema for `ysql_config.log_settings`

Read-Only:

- `log_catalog` (Boolean) These system catalog tables record system (as opposed to user) activity, such as metadata lookups and from third-party tools performing lookups
- `log_client` (Boolean) Enable this option to echo log messages directly to clients such as ysqlsh and psql
- `log_level` (String) Sets the severity level of logs written to clients
- `log_parameter` (Boolean) Include the parameters that were passed with the statement in the logs
- `log_relation` (Boolean) Create separate log entries for each relation (TABLE, VIEW, and so on) referenced in a SELECT or DML statement
- `log_statement_once` (Boolean) Enable this setting to only include statement text and parameters for the first entry for a statement or sub-statement combination
70 changes: 70 additions & 0 deletions docs/resources/db_audit_logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ybm_db_audit_logging Resource - ybm"
subcategory: ""
description: |-
The resource to manage DB Audit log configuration for a cluster in YugabyteDB Aeon.
---

# ybm_db_audit_logging (Resource)

The resource to manage DB Audit log configuration for a cluster in YugabyteDB Aeon.

## Example Usage

```terraform
# DB audit log configuration for a cluster
resource "ybm_db_audit_logging" "sample-db-audit-log-config" {
cluster_id = "<Your-Cluster-Id>"
integration_name = "<Your-Integration-Name>"
ysql_config = {
log_settings = {
log_catalog = true
log_client = false
log_relation = true
log_level = "LOG"
log_statement_once = true
log_parameter = false
}
statement_classes = ["READ", "WRITE", "ROLE"]
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cluster_id` (String) ID of the cluster from which DB Audit Logs will be exported
- `integration_name` (String) Name of the integration to which the DB Audit Logs will be exported
- `ysql_config` (Attributes) The specification for a DB Audit ysql export configuration (see [below for nested schema](#nestedatt--ysql_config))

### Read-Only

- `account_id` (String) ID of the account this DB Audit log configuration belongs to.
- `cluster_name` (String) Name of the cluster from which DB Audit Logs will be exported
- `config_id` (String) ID of the DB Audit logging configuration
- `integration_id` (String) ID of the integration to which the DB Audit Logs will be exported
- `project_id` (String) ID of the project this DB Audit log configuration belongs to.
- `state` (String) The status of DB Audit Logging on the cluster

<a id="nestedatt--ysql_config"></a>
### Nested Schema for `ysql_config`

Required:

- `log_settings` (Attributes) Db Audit Ysql Log Settings (see [below for nested schema](#nestedatt--ysql_config--log_settings))
- `statement_classes` (Set of String) List of ysql statements

<a id="nestedatt--ysql_config--log_settings"></a>
### Nested Schema for `ysql_config.log_settings`

Optional:

- `log_catalog` (Boolean) These system catalog tables record system (as opposed to user) activity, such as metadata lookups and from third-party tools performing lookups. Defaults to 'true' if not specified.
- `log_client` (Boolean) Enable this option to echo log messages directly to clients such as ysqlsh and psql. Defaults to 'true' if not specified
- `log_level` (String) Sets the severity level of logs written to clients. Defaults to 'LOG' if not specified
- `log_parameter` (Boolean) Include the parameters that were passed with the statement in the logs. Defaults to 'false' if not specified
- `log_relation` (Boolean) Create separate log entries for each relation (TABLE, VIEW, and so on) referenced in a SELECT or DML statement. Defaults to 'false' if not specified
- `log_statement_once` (Boolean) Enable this setting to only include statement text and parameters for the first entry for a statement or sub-statement combination. Defaults to 'false' if not specified
2 changes: 1 addition & 1 deletion managed/data_source_db_audit_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type dataSourceDbAuditLoggingType struct{}

func (r dataSourceDbAuditLoggingType) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: `The data source to fetch DB Audit log configuration for a cluster given cluster ID or configuration ID in YugabyteDB Aeon.`,
Description: `The data source to fetch DB Audit log configuration for a cluster given cluster ID in YugabyteDB Aeon.`,
Attributes: map[string]tfsdk.Attribute{
"account_id": {
Description: "ID of the account this DB Audit log configuration belongs to.",
Expand Down
2 changes: 0 additions & 2 deletions managed/fflags/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ type FeatureFlag string

const (
GOOGLECLOUD_INTEGRATION_ENABLED FeatureFlag = "GOOGLECLOUD_INTEGRATION_ENABLED"
DB_AUDIT_LOGGING FeatureFlag = "DB_AUDIT_LOGGING"
CONNECTION_POOLING FeatureFlag = "CONNECTION_POOLING"
DR FeatureFlag = "DR"
)

var flagEnabled = map[FeatureFlag]bool{
GOOGLECLOUD_INTEGRATION_ENABLED: false,
DB_AUDIT_LOGGING: false,
CONNECTION_POOLING: false,
DR: false,
}
Expand Down
22 changes: 7 additions & 15 deletions managed/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ func (p *provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp
"ybm_associate_metrics_exporter_cluster": resourceAssociateMetricsExporterClusterType{},
"ybm_integration": resourceIntegrationType{},
"ybm_db_query_logging": resourceDbQueryLoggingType{},
}

// Add DB Audit logging resource only if the feature flag is enabled
if fflags.IsFeatureFlagEnabled(fflags.DB_AUDIT_LOGGING) {
resources["ybm_db_audit_logging"] = resourceDbAuditLoggingType{}
"ybm_db_audit_logging": resourceDbAuditLoggingType{},
}

// Add DR config resource only if the feature flag is enabled
Expand All @@ -175,16 +171,12 @@ func (p *provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp

func (p *provider) GetDataSources(_ context.Context) (map[string]tfsdk.DataSourceType, diag.Diagnostics) {
dataSources := map[string]tfsdk.DataSourceType{
"ybm_backup": dataSourceBackupType{},
"ybm_cluster": dataClusterNameType{},
"ybm_vpc": dataSourceVPCType{},
"ybm_allow_list": dataSourceAllowListType{},
"ybm_integration": dataSourceIntegrationType{},
}

// Add DB Audit logging data source only if the feature flag is enabled
if fflags.IsFeatureFlagEnabled(fflags.DB_AUDIT_LOGGING) {
dataSources["ybm_db_audit_logging"] = dataSourceDbAuditLoggingType{}
"ybm_backup": dataSourceBackupType{},
"ybm_cluster": dataClusterNameType{},
"ybm_vpc": dataSourceVPCType{},
"ybm_allow_list": dataSourceAllowListType{},
"ybm_integration": dataSourceIntegrationType{},
"ybm_db_audit_logging": dataSourceDbAuditLoggingType{},
}

return dataSources, nil
Expand Down

0 comments on commit 7c17d25

Please sign in to comment.