Skip to content

Commit 7b8a8a4

Browse files
committed
feat: adding source_ips and global_source_ips to data sources
1 parent 4874506 commit 7b8a8a4

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

docs/data-sources/rediscloud_active_active_subscription_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ data "rediscloud_active_active_subscription_database" "example" {
4949
* `external_endpoint_for_oss_cluster_api` - Use the external endpoint for open-source (OSS) Cluster API.
5050
* `enable_tls` - Enable TLS for database.
5151
* `tls_certificate` - TLS certificate used for authentication.
52+
* `global_source_ips` - Set of CIDR addresses to allow access to the database.
5253
* `data_eviction` - The data items eviction policy.
5354
* `global_modules` - A list of modules to be enabled on all deployments of this database.
5455
* `public_endpoint` - Public endpoint to access the database.

docs/data-sources/rediscloud_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ data "rediscloud_database" "example" {
6363
* `private_endpoint` - Private endpoint to access the database
6464
* `enable_tls` - Enable TLS for database, default is `false`
6565
* `enable_default_user` - When `true` enables connecting to the database with the default user. Default `true`.
66+
* `source_ips` - Set of CIDR addresses to allow access to the database.
6667
* `latest_backup_status` - A latest_backup_status object, documented below.
6768
* `latest_import_status` - A latest_import_status object, documented below.
6869
* `tags` - A string/string map of all Tags associated with this database.

provider/datasource_rediscloud_active_active_database.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ func dataSourceRedisCloudActiveActiveDatabase() *schema.Resource {
241241
},
242242
Computed: true,
243243
},
244+
"global_source_ips": {
245+
Description: "Set of CIDR addresses to allow access to the database",
246+
Type: schema.TypeSet,
247+
Computed: true,
248+
Elem: &schema.Schema{
249+
Type: schema.TypeString,
250+
},
251+
},
244252
},
245253
}
246254
}
@@ -388,6 +396,13 @@ func dataSourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema
388396
}
389397
}
390398

399+
// Set global_source_ips from the first region database
400+
if len(db.CrdbDatabases) > 0 && db.CrdbDatabases[0].Security != nil {
401+
if err := d.Set("global_source_ips", redis.StringSliceValue(db.CrdbDatabases[0].Security.SourceIPs...)); err != nil {
402+
return diag.FromErr(err)
403+
}
404+
}
405+
391406
return diags
392407
}
393408

provider/pro/datasource_rediscloud_pro_database.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,15 @@ func DataSourceRedisCloudProDatabase() *schema.Resource {
313313
},
314314
Computed: true,
315315
},
316+
"source_ips": {
317+
Description: "Set of CIDR addresses to allow access to the database",
318+
Type: schema.TypeSet,
319+
Computed: true,
320+
Elem: &schema.Schema{
321+
Type: schema.TypeString,
322+
ValidateDiagFunc: validation.ToDiagFunc(validation.IsCIDR),
323+
},
324+
},
316325
},
317326
}
318327
}
@@ -454,6 +463,9 @@ func dataSourceRedisCloudProDatabaseRead(ctx context.Context, d *schema.Resource
454463
if err := d.Set("enable_default_user", redis.BoolValue(db.Security.EnableDefaultUser)); err != nil {
455464
return diag.FromErr(err)
456465
}
466+
if err := d.Set("source_ips", redis.StringSliceValue(db.Security.SourceIPs...)); err != nil {
467+
return diag.FromErr(err)
468+
}
457469
}
458470

459471
var parsedLatestBackupStatus []map[string]interface{}

0 commit comments

Comments
 (0)