-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Ved misra <47312748+misraved@users.noreply.github.com>
- Loading branch information
1 parent
1950e41
commit e931285
Showing
7 changed files
with
706 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Table: gcp_redis_instance | ||
|
||
In Memorystore for Redis, an instance refers to an in-memory Redis data store. Memorystore for Redis Instances are also referred to as Redis instances. When you create a new Memorystore for Redis instance, you are creating a new Redis data store. | ||
|
||
## Examples | ||
|
||
### Basic info | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
memory_size_gb, | ||
reserved_ip_range | ||
from | ||
gcp_redis_instance; | ||
``` | ||
|
||
### List instances that have authentication enabled | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
memory_size_gb, | ||
reserved_ip_range | ||
from | ||
gcp_redis_instance | ||
where | ||
auth_enabled; | ||
``` | ||
|
||
### List instances created in the last 7 days | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
memory_size_gb, | ||
reserved_ip_range | ||
from | ||
gcp_redis_instance | ||
where | ||
create_time >= current_timestamp - interval '7 days'; | ||
``` | ||
|
||
### List the node details of each instance | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
jsonb_pretty(nodes) as instance_nodes | ||
from | ||
gcp_redis_instance | ||
where | ||
name = 'instance-test' | ||
and location_id = 'europe-west3-c'; | ||
``` | ||
|
||
### List instances encrypted with customer-managed keys | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
memory_size_gb, | ||
reserved_ip_range | ||
from | ||
gcp_redis_instance | ||
where | ||
customer_managed_key is not null; | ||
``` | ||
|
||
### List instances that have transit mode disabled | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
memory_size_gb, | ||
reserved_ip_range | ||
from | ||
gcp_redis_instance | ||
where | ||
transit_encryption_mode = 2; | ||
``` | ||
|
||
### List the maintenance details of instances | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
maintenance_policy, | ||
maintenance_schedule, | ||
maintenance_version, | ||
available_maintenance_versions | ||
from | ||
gcp_redis_instance; | ||
``` | ||
|
||
### List instances with direct peering access | ||
|
||
```sql | ||
select | ||
name, | ||
display_name, | ||
create_time, | ||
location_id, | ||
memory_size_gb, | ||
reserved_ip_range | ||
from | ||
gcp_redis_instance | ||
where | ||
connect_mode = 1; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package gcp | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin" | ||
"google.golang.org/api/iterator" | ||
"google.golang.org/genproto/googleapis/cloud/location" | ||
) | ||
|
||
const matrixKeyRedisLocation = "redis-location" | ||
|
||
// BuildRedisLocationList :: return a list of matrix items, one per region specified | ||
func BuildRedisLocationList(ctx context.Context, d *plugin.QueryData) []map[string]interface{} { | ||
|
||
// have we already created and cached the locations? | ||
locationCacheKey := "RedisLocation" | ||
if cachedData, ok := d.ConnectionManager.Cache.Get(locationCacheKey); ok { | ||
plugin.Logger(ctx).Trace("listlocationDetails:", cachedData.([]map[string]interface{})) | ||
return cachedData.([]map[string]interface{}) | ||
} | ||
|
||
// Create Service Connection | ||
service, err := RedisService(ctx, d) | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
projectData, err := activeProject(ctx, d) | ||
if err != nil { | ||
return nil | ||
} | ||
project := projectData.Project | ||
if project == "" { | ||
return nil | ||
} | ||
|
||
req := &location.ListLocationsRequest{ | ||
Name: "projects/" + project, | ||
PageSize: 100, | ||
} | ||
|
||
it := service.ListLocations(ctx, req) | ||
matrix := []map[string]interface{}{} | ||
for { | ||
resp, err := it.Next() | ||
if err != nil { | ||
if err == iterator.Done { | ||
break | ||
} | ||
return nil | ||
} | ||
obj := map[string]interface{}{matrixKeyRedisLocation: resp.LocationId} | ||
matrix = append(matrix, obj) | ||
} | ||
|
||
d.ConnectionManager.Cache.Set(locationCacheKey, matrix) | ||
return matrix | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.