Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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|
Expand All @@ -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|
|version (PK)|String|
6 changes: 3 additions & 3 deletions plugins/source/aws/docs/tables/aws_ram_resource_shares.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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|
Expand Down
8 changes: 4 additions & 4 deletions plugins/source/aws/docs/tables/aws_ram_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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|
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,6 +25,14 @@ func ResourceShareInvitations() *schema.Table {
PrimaryKey: true,
},
},
{
Name: "receiver_combined",
Comment thread
candiduslynx marked this conversation as resolved.
Type: schema.TypeString,
Resolver: resolveResourceShareInvitationReceiver,
CreationOptions: schema.ColumnCreationOptions{
PrimaryKey: true,
},
},
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 3 additions & 11 deletions plugins/source/aws/resources/services/ram/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
}