Skip to content

Commit 8029e57

Browse files
committed
Add table gcp_storage_object. Closes #459
1 parent 2700f6d commit 8029e57

File tree

3 files changed

+418
-0
lines changed

3 files changed

+418
-0
lines changed

docs/tables/gcp_storage_object.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Table: gcp_storage_object
2+
3+
Storage buckets are the basic containers that hold data. Everything that you store in cloud Storage must be contained in a bucket.
4+
5+
## Examples
6+
7+
### Basic info
8+
9+
```sql
10+
select
11+
id,
12+
name,
13+
bucket,
14+
content_type,
15+
generation,
16+
size,
17+
storage_class,
18+
time_created,
19+
owner
20+
from
21+
gcp_storage_object;
22+
```
23+
24+
### List storage objects encrypted with customer managed keys
25+
26+
```sql
27+
select
28+
id,
29+
name,
30+
bucket
31+
from
32+
gcp_storage_object
33+
where
34+
not kms_key_name is not null;
35+
```
36+
37+
### Get total objects and size of each bucket
38+
39+
```sql
40+
select
41+
bucket,
42+
count(*) as total_objects,
43+
sum(size) as total_size_bytes
44+
from
45+
gcp_storage_object
46+
group by
47+
bucket;
48+
```
49+
50+
### List of members and their associated iam roles for each objects
51+
52+
```sql
53+
select
54+
bucket,
55+
name,
56+
p -> 'members' as member,
57+
p ->> 'role' as role,
58+
p ->> 'version' as version
59+
from
60+
gcp_storage_object,
61+
jsonb_array_elements(iam_policy -> 'bindings') as p;
62+
```
63+
64+
### List of storage objects whose retention period is less than 7 days
65+
66+
```sql
67+
select
68+
bucket,
69+
name,
70+
extract(epoch from (retention_expiration_time - current_timestamp)) as retention_period_secs
71+
from
72+
gcp_storage_object
73+
where
74+
extract(epoch from (retention_expiration_time - current_timestamp)) < 604800;
75+
```

gcp/plugin.go

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
119119
"gcp_sql_database_instance_metric_cpu_utilization_daily": tableGcpSQLDatabaseInstanceMetricCpuUtilizationDaily(ctx),
120120
"gcp_sql_database_instance_metric_cpu_utilization_hourly": tableGcpSQLDatabaseInstanceMetricCpuUtilizationHourly(ctx),
121121
"gcp_storage_bucket": tableGcpStorageBucket(ctx),
122+
"gcp_storage_object": tableGcpStorageObject(ctx),
122123
/*
123124
https://github.com/turbot/steampipe/issues/108
124125
"gcp_compute_route": tableGcpComputeRoute(ctx),

0 commit comments

Comments
 (0)