Skip to content

Commit 681ea97

Browse files
authored
feat(aws)!: Define composite primary key for regions (#12415)
#### Summary This PR is aimed to address #12414 by creating a composite primary key on `aws_regions` table comprising `account_id` and `region`. With this key there will be one set of regions (27) per discovered AWS Account. The reason why we're not limiting them to only one set of regions for all accounts is that different AWS Accounts can have different `opt_in_status` / `enabled` values for different regions.
1 parent bd22651 commit 681ea97

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

plugins/source/aws/resources/services/ec2/regions.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func Regions() *schema.Table {
2121
Multiplex: client.AccountMultiplex(tableName),
2222
Transform: transformers.TransformWithStruct(&types.Region{}),
2323
Columns: []schema.Column{
24-
client.DefaultAccountIDColumn(false),
24+
client.DefaultAccountIDColumn(true),
2525
{
2626
Name: "enabled",
2727
Type: arrow.FixedWidthTypes.Boolean,
@@ -33,9 +33,10 @@ func Regions() *schema.Table {
3333
Resolver: client.ResolveAWSPartition,
3434
},
3535
{
36-
Name: "region",
37-
Type: arrow.BinaryTypes.String,
38-
Resolver: schema.PathResolver("RegionName"),
36+
Name: "region",
37+
Type: arrow.BinaryTypes.String,
38+
Resolver: schema.PathResolver("RegionName"),
39+
PrimaryKey: true,
3940
},
4041
},
4142
}

website/tables/aws/aws_regions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ This table shows data for Regions.
44

55
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Region.html
66

7-
The primary key for this table is **_cq_id**.
7+
The composite primary key for this table is (**account_id**, **region**).
88

99
## Columns
1010

1111
| Name | Type |
1212
| ------------- | ------------- |
13-
|_cq_id (PK)|`uuid`|
13+
|_cq_id|`uuid`|
1414
|_cq_parent_id|`uuid`|
15-
|account_id|`utf8`|
15+
|account_id (PK)|`utf8`|
1616
|enabled|`bool`|
1717
|partition|`utf8`|
18-
|region|`utf8`|
18+
|region (PK)|`utf8`|
1919
|endpoint|`utf8`|
2020
|opt_in_status|`utf8`|
2121
|region_name|`utf8`|

0 commit comments

Comments
 (0)