diff --git a/plugins/source/aws/docs/tables/aws_ram_resource_share_associations.md b/plugins/source/aws/docs/tables/aws_ram_resource_share_associations.md index 792cb3ba728123..e0d0460fb45648 100644 --- a/plugins/source/aws/docs/tables/aws_ram_resource_share_associations.md +++ b/plugins/source/aws/docs/tables/aws_ram_resource_share_associations.md @@ -15,11 +15,11 @@ The composite primary key for this table is (**associated_entity**, **resource_s |account_id|String| |region|String| |associated_entity (PK)|String| -|resource_share_arn (PK)|String| |association_type|String| |creation_time|Timestamp| |external|Bool| |last_updated_time|Timestamp| +|resource_share_arn (PK)|String| |resource_share_name|String| |status|String| |status_message|String| \ No newline at end of file diff --git a/plugins/source/aws/docs/tables/aws_ram_resource_share_invitations.md b/plugins/source/aws/docs/tables/aws_ram_resource_share_invitations.md index e647fc8d1cf56c..79c1e1312a3e66 100644 --- a/plugins/source/aws/docs/tables/aws_ram_resource_share_invitations.md +++ b/plugins/source/aws/docs/tables/aws_ram_resource_share_invitations.md @@ -2,7 +2,7 @@ https://docs.aws.amazon.com/ram/latest/APIReference/API_ResourceShareInvitation.html -The primary key for this table is **arn**. +The composite primary key for this table is (**account_id**, **region**, **arn**, **receiver_combined**). ## Columns @@ -12,9 +12,10 @@ The primary key for this table is **arn**. |_cq_sync_time|Timestamp| |_cq_id|UUID| |_cq_parent_id|UUID| -|account_id|String| -|region|String| +|account_id (PK)|String| +|region (PK)|String| |arn (PK)|String| +|receiver_combined (PK)|String| |invitation_timestamp|Timestamp| |receiver_account_id|String| |receiver_arn|String| diff --git a/plugins/source/aws/docs/tables/aws_ram_resource_share_permissions.md b/plugins/source/aws/docs/tables/aws_ram_resource_share_permissions.md index 70d51aec42a6b8..e9a0641780822d 100644 --- a/plugins/source/aws/docs/tables/aws_ram_resource_share_permissions.md +++ b/plugins/source/aws/docs/tables/aws_ram_resource_share_permissions.md @@ -2,7 +2,7 @@ https://docs.aws.amazon.com/ram/latest/APIReference/API_ResourceSharePermissionSummary.html -The primary key for this table is **arn**. +The composite primary key for this table is (**account_id**, **region**, **arn**, **version**). ## Relations @@ -16,8 +16,8 @@ This table depends on [aws_ram_resource_shares](aws_ram_resource_shares.md). |_cq_sync_time|Timestamp| |_cq_id|UUID| |_cq_parent_id|UUID| -|account_id|String| -|region|String| +|account_id (PK)|String| +|region (PK)|String| |permission|JSON| |arn (PK)|String| |creation_time|Timestamp| @@ -27,4 +27,4 @@ This table depends on [aws_ram_resource_shares](aws_ram_resource_shares.md). |name|String| |resource_type|String| |status|String| -|version|String| \ No newline at end of file +|version (PK)|String| \ No newline at end of file diff --git a/plugins/source/aws/docs/tables/aws_ram_resource_shares.md b/plugins/source/aws/docs/tables/aws_ram_resource_shares.md index 5d7f2c357e4c5d..1e4384eb0eda33 100644 --- a/plugins/source/aws/docs/tables/aws_ram_resource_shares.md +++ b/plugins/source/aws/docs/tables/aws_ram_resource_shares.md @@ -2,7 +2,7 @@ https://docs.aws.amazon.com/ram/latest/APIReference/API_ResourceShare.html -The primary key for this table is **arn**. +The composite primary key for this table is (**account_id**, **region**, **arn**). ## Relations @@ -17,8 +17,8 @@ The following tables depend on aws_ram_resource_shares: |_cq_sync_time|Timestamp| |_cq_id|UUID| |_cq_parent_id|UUID| -|account_id|String| -|region|String| +|account_id (PK)|String| +|region (PK)|String| |arn (PK)|String| |tags|JSON| |allow_external_principals|Bool| diff --git a/plugins/source/aws/docs/tables/aws_ram_resources.md b/plugins/source/aws/docs/tables/aws_ram_resources.md index 48f5d34d8bc990..d7c31584bec113 100644 --- a/plugins/source/aws/docs/tables/aws_ram_resources.md +++ b/plugins/source/aws/docs/tables/aws_ram_resources.md @@ -2,7 +2,7 @@ https://docs.aws.amazon.com/ram/latest/APIReference/API_Resource.html -The primary key for this table is **arn**. +The composite primary key for this table is (**account_id**, **region**, **arn**, **resource_share_arn**). ## Columns @@ -12,14 +12,14 @@ The primary key for this table is **arn**. |_cq_sync_time|Timestamp| |_cq_id|UUID| |_cq_parent_id|UUID| -|account_id|String| -|region|String| +|account_id (PK)|String| +|region (PK)|String| |arn (PK)|String| |creation_time|Timestamp| |last_updated_time|Timestamp| |resource_group_arn|String| |resource_region_scope|String| -|resource_share_arn|String| +|resource_share_arn (PK)|String| |status|String| |status_message|String| |type|String| \ No newline at end of file diff --git a/plugins/source/aws/resources/services/ram/resource_share_associations.go b/plugins/source/aws/resources/services/ram/resource_share_associations.go index 9f0ba62b24e57f..6dfdc1fc8d0081 100644 --- a/plugins/source/aws/resources/services/ram/resource_share_associations.go +++ b/plugins/source/aws/resources/services/ram/resource_share_associations.go @@ -12,27 +12,11 @@ func ResourceShareAssociations() *schema.Table { Name: "aws_ram_resource_share_associations", Description: `https://docs.aws.amazon.com/ram/latest/APIReference/API_ResourceShareAssociation.html`, Resolver: fetchRamResourceShareAssociations, - Transform: transformers.TransformWithStruct(&types.ResourceShareAssociation{}), + Transform: transformers.TransformWithStruct(&types.ResourceShareAssociation{}, transformers.WithPrimaryKeys("AssociatedEntity", "ResourceShareArn")), Multiplex: client.ServiceAccountRegionMultiplexer("ram"), Columns: []schema.Column{ client.DefaultAccountIDColumn(false), client.DefaultRegionColumn(false), - { - Name: "associated_entity", - Type: schema.TypeString, - Resolver: schema.PathResolver("AssociatedEntity"), - CreationOptions: schema.ColumnCreationOptions{ - PrimaryKey: true, - }, - }, - { - Name: "resource_share_arn", - Type: schema.TypeString, - Resolver: schema.PathResolver("ResourceShareArn"), - CreationOptions: schema.ColumnCreationOptions{ - PrimaryKey: true, - }, - }, }, } } diff --git a/plugins/source/aws/resources/services/ram/resource_share_invitations.go b/plugins/source/aws/resources/services/ram/resource_share_invitations.go index 32e629c369b6e3..26186c136abb0d 100644 --- a/plugins/source/aws/resources/services/ram/resource_share_invitations.go +++ b/plugins/source/aws/resources/services/ram/resource_share_invitations.go @@ -15,8 +15,8 @@ func ResourceShareInvitations() *schema.Table { Transform: transformers.TransformWithStruct(&types.ResourceShareInvitation{}), Multiplex: client.ServiceAccountRegionMultiplexer("ram"), Columns: []schema.Column{ - client.DefaultAccountIDColumn(false), - client.DefaultRegionColumn(false), + client.DefaultAccountIDColumn(true), + client.DefaultRegionColumn(true), { Name: "arn", Type: schema.TypeString, @@ -25,6 +25,14 @@ func ResourceShareInvitations() *schema.Table { PrimaryKey: true, }, }, + { + Name: "receiver_combined", + Type: schema.TypeString, + Resolver: resolveResourceShareInvitationReceiver, + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, + }, }, } } diff --git a/plugins/source/aws/resources/services/ram/resource_share_invitations_fetch.go b/plugins/source/aws/resources/services/ram/resource_share_invitations_fetch.go index 5461bbfe087239..00943ff8b55416 100644 --- a/plugins/source/aws/resources/services/ram/resource_share_invitations_fetch.go +++ b/plugins/source/aws/resources/services/ram/resource_share_invitations_fetch.go @@ -2,9 +2,11 @@ package ram import ( "context" + "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ram" + "github.com/aws/aws-sdk-go-v2/service/ram/types" "github.com/cloudquery/cloudquery/plugins/source/aws/client" "github.com/cloudquery/plugin-sdk/schema" ) @@ -27,3 +29,14 @@ func fetchRamResourceShareInvitations(ctx context.Context, meta schema.ClientMet } return nil } + +func resolveResourceShareInvitationReceiver(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { + inv := resource.Item.(types.ResourceShareInvitation) + if inv.ReceiverArn != nil { + return resource.Set(c.Name, *inv.ReceiverArn) + } + if inv.ReceiverAccountId != nil { + return resource.Set(c.Name, *inv.ReceiverAccountId) + } + return fmt.Errorf("aws:ram invitation receiver both account and arn is missing") +} diff --git a/plugins/source/aws/resources/services/ram/resource_share_permissions.go b/plugins/source/aws/resources/services/ram/resource_share_permissions.go index fb668595c87056..b9c50bab2998a5 100644 --- a/plugins/source/aws/resources/services/ram/resource_share_permissions.go +++ b/plugins/source/aws/resources/services/ram/resource_share_permissions.go @@ -11,24 +11,16 @@ func ResourceSharePermissions() *schema.Table { return &schema.Table{ Name: "aws_ram_resource_share_permissions", Description: `https://docs.aws.amazon.com/ram/latest/APIReference/API_ResourceSharePermissionSummary.html`, - Transform: transformers.TransformWithStruct(&types.ResourceSharePermissionSummary{}), + Transform: transformers.TransformWithStruct(&types.ResourceSharePermissionSummary{}, transformers.WithPrimaryKeys("Arn", "Version")), Resolver: fetchRamResourceSharePermissions, Columns: []schema.Column{ - client.DefaultAccountIDColumn(false), - client.DefaultRegionColumn(false), + client.DefaultAccountIDColumn(true), + client.DefaultRegionColumn(true), { Name: "permission", Type: schema.TypeJSON, Resolver: resolveResourceSharePermissionDetailPermission, }, - { - Name: "arn", - Type: schema.TypeString, - Resolver: schema.PathResolver("Arn"), - CreationOptions: schema.ColumnCreationOptions{ - PrimaryKey: true, - }, - }, }, } } diff --git a/plugins/source/aws/resources/services/ram/resource_shares.go b/plugins/source/aws/resources/services/ram/resource_shares.go index a20c15b0380c66..8faef11498f48e 100644 --- a/plugins/source/aws/resources/services/ram/resource_shares.go +++ b/plugins/source/aws/resources/services/ram/resource_shares.go @@ -15,8 +15,8 @@ func ResourceShares() *schema.Table { Transform: transformers.TransformWithStruct(&types.ResourceShare{}), Multiplex: client.ServiceAccountRegionMultiplexer("ram"), Columns: []schema.Column{ - client.DefaultAccountIDColumn(false), - client.DefaultRegionColumn(false), + client.DefaultAccountIDColumn(true), + client.DefaultRegionColumn(true), { Name: "arn", Type: schema.TypeString, diff --git a/plugins/source/aws/resources/services/ram/resources.go b/plugins/source/aws/resources/services/ram/resources.go index 87094efccb81e7..2516f5e000ef4f 100644 --- a/plugins/source/aws/resources/services/ram/resources.go +++ b/plugins/source/aws/resources/services/ram/resources.go @@ -12,19 +12,11 @@ func Resources() *schema.Table { Name: "aws_ram_resources", Description: `https://docs.aws.amazon.com/ram/latest/APIReference/API_Resource.html`, Resolver: fetchRamResources, - Transform: transformers.TransformWithStruct(&types.Resource{}), + Transform: transformers.TransformWithStruct(&types.Resource{}, transformers.WithPrimaryKeys("Arn", "ResourceShareArn")), Multiplex: client.ServiceAccountRegionMultiplexer("ram"), Columns: []schema.Column{ - client.DefaultAccountIDColumn(false), - client.DefaultRegionColumn(false), - { - Name: "arn", - Type: schema.TypeString, - Resolver: schema.PathResolver("Arn"), - CreationOptions: schema.ColumnCreationOptions{ - PrimaryKey: true, - }, - }, + client.DefaultAccountIDColumn(true), + client.DefaultRegionColumn(true), }, } }