Skip to content

Commit 00ca437

Browse files
authored
fix(gcp-resources): Add project_id and name as PKs of gcp_iam_service_account_keys, remove service_account_unique_id from PKs (#6541)
#### Summary `gcp_iam_service_account_keys` used the parent resource `unique_id` as a primary key. This meant we can only sync 1 account key per account in `overwrite*` modes. This PR makes it so `project_id` and `name` are the primary keys, removes `service_account_unique_id` as a primary (but keeps the data). This should be a non breaking change <!--
1 parent 3d4d03c commit 00ca437

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

plugins/source/gcp/docs/tables/gcp_iam_service_account_keys.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
https://cloud.google.com/iam/docs/reference/rest/v1/projects.serviceAccounts.keys#ServiceAccountKey
44

5-
The primary key for this table is **service_account_unique_id**.
5+
The composite primary key for this table is (**project_id**, **name**).
66

77
## Relations
88

@@ -16,9 +16,9 @@ This table depends on [gcp_iam_service_accounts](gcp_iam_service_accounts.md).
1616
|_cq_sync_time|Timestamp|
1717
|_cq_id|UUID|
1818
|_cq_parent_id|UUID|
19-
|project_id|String|
20-
|service_account_unique_id (PK)|String|
21-
|name|String|
19+
|project_id (PK)|String|
20+
|service_account_unique_id|String|
21+
|name (PK)|String|
2222
|key_algorithm|String|
2323
|public_key_data|IntArray|
2424
|valid_after_time|Timestamp|

plugins/source/gcp/resources/services/iam/service_account_keys.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@ func ServiceAccountKeys() *schema.Table {
1919
Name: "project_id",
2020
Type: schema.TypeString,
2121
Resolver: client.ResolveProject,
22+
CreationOptions: schema.ColumnCreationOptions{
23+
PrimaryKey: true,
24+
},
2225
},
2326
{
2427
Name: "service_account_unique_id",
2528
Type: schema.TypeString,
2629
Resolver: schema.ParentColumnResolver("unique_id"),
30+
},
31+
{
32+
Name: "name",
33+
Type: schema.TypeString,
34+
Resolver: schema.PathResolver("Name"),
2735
CreationOptions: schema.ColumnCreationOptions{
2836
PrimaryKey: true,
2937
},

0 commit comments

Comments
 (0)