Skip to content

Conversation

@disq
Copy link
Member

@disq disq commented Feb 14, 2023

The issue is the resource being shared so it's not located in the same account as it's owner. So if the user is fetching multiple accounts which have the resource share/share_perms the ARN clash is inevitable.

Test Results

  • For aws_ram_resources: arn is the shared resource, resource_share_arn is the arn of the share itself, so both need to be in the PK, as well as AccountId and Region, because of the sharer/sharee being able to both view the same record.
  • For aws_ram_resource_shares, the ARN's account_id/region is from the owner account and it has a UUID at the end of the ARN. So if you're sharing between two of your accounts the ARN clash is issue is real, adding current account/region from the querying account solves the problem.
  • For the aws_ram_resource_share_permissions, the ARN is the arn of the permission itself, without any region or account or version, as in: arn:aws:ram::aws:permission/AWSRAMDefaultPermissionGlueDatabase and such (real value from test account) so adding the version and the account_id/region made sense.
  • For aws_ram_resource_share_associations, there's no issue because the share "grantee" doesn't seem have access to the this list, it's only filled from the sharer account side.
  • For aws_ram_principals, the previous PR fix(aws)!: Add resource_share_arn and region to aws_ram_principals PK #7985 seems to have fixed the issue, it's the same thing as the aws_ram_resource_shares issue.
  • For aws_ram_resource_share_invitations, the ARN of the invitation is different from the resource share. But since you can share to multiple accounts or other entities (IAM users, etc) ReceiverAccountId and ReceiverArn needs to be added to the PK list. The problem is, ReceiverArn can be empty on some cases (if shared to account it's definitely empty) so it can't be a PK as-is. I added a new receiver_combined column to remedy the issue.

@github-actions
Copy link

github-actions bot commented Feb 14, 2023

This PR has the following changes to source plugin(s) tables:

  • Table aws_ram_resource_share_associations: column order changed for resource_share_arn
  • ⚠️ BREAKING CHANGE: Table aws_ram_resource_share_invitations: column added with name receiver_combined (PK) and type String
  • Table aws_ram_resource_share_invitations: primary key constraint added to column account_id
  • Table aws_ram_resource_share_invitations: primary key constraint added to column region
  • Table aws_ram_resource_share_permissions: primary key constraint added to column account_id
  • Table aws_ram_resource_share_permissions: primary key constraint added to column region
  • Table aws_ram_resource_share_permissions: primary key constraint added to column version
  • Table aws_ram_resource_shares: primary key constraint added to column account_id
  • Table aws_ram_resource_shares: primary key constraint added to column region
  • Table aws_ram_resources: primary key constraint added to column account_id
  • Table aws_ram_resources: primary key constraint added to column region
  • Table aws_ram_resources: primary key constraint added to column resource_share_arn

@erezrokah erezrokah changed the title fix(aws): RAM resource shares and resource share permissions PK fix fix(aws)!: Add account_id and region to aws_ram_resource_shares and aws_ram_resource_share_permissions PKs Feb 14, 2023
@erezrokah
Copy link
Member

erezrokah commented Feb 14, 2023

Made this a breaking change via the PR title. With #7819 we consider any PK change to require a forced migration

@disq disq changed the title fix(aws)!: Add account_id and region to aws_ram_resource_shares and aws_ram_resource_share_permissions PKs fix(aws)!: Resource Access Manager (RAM) PK issues Feb 14, 2023
@disq disq requested a review from candiduslynx February 14, 2023 11:29
@candiduslynx candiduslynx added automerge Automatically merge once required checks pass priority merge and removed no automerge labels Feb 14, 2023
@kodiakhq kodiakhq bot merged commit 901dcf4 into cloudquery:main Feb 14, 2023
@disq disq deleted the fix/aws_pk_ram_resource_shares branch February 14, 2023 13:04
kodiakhq bot pushed a commit that referenced this pull request Feb 14, 2023
🤖 I have created a release *beep* *boop*
---


## [14.0.0](plugins-source-aws-v13.3.0...plugins-source-aws-v14.0.0) (2023-02-14)


### ⚠ BREAKING CHANGES

* **aws:** Use `log_group_arn` + `filter_name` for `aws_cloudwatchlogs_metric_filters` PK ([#8061](#8061))
* **aws:** Add `account_id` and `region` to `aws_ec2_transit_gateways` PK ([#8060](#8060))
* **aws:** Rename `user_arn` field to `arn` in `aws_quicksight_group_members`
* **aws:** Resource Access Manager (RAM) PK issues ([#8010](#8010))
* **aws:** Add `resource_share_arn` and `region` to `aws_ram_principals` PK ([#7985](#7985))
* **aws:** Add `account_id` and `region` to PK in `aws_directconnect_gateways` ([#7984](#7984))
* **aws:** Use `physical_resource_identifier` instead of `physical_resource_id` in `aws_resiliencehub_app_version_resources` and `aws_resiliencehub_app_version_resource_mappings` PKs
* **aws:** PK for `aws_s3_bucket_grants` ([#7822](#7822))
* **aws:** PK for `aws_docdb_certificates` ([#7820](#7820))
* **aws:** PK for `aws_ec2_images` ([#7821](#7821))
* **aws:** Fix PK  for `aws_rds_certificates` ([#7817](#7817))

### Features

* Athena resource view creation ([#7908](#7908)) ([a8769ea](a8769ea))
* **aws-resources:** Add EMR Cluster Instances ([#7814](#7814)) ([f2883d0](f2883d0))
* **aws-resources:** Add EMR Instance Fleets and Groups ([#7818](#7818)) ([df8cfea](df8cfea))
* **aws-resources:** Add EMR Security Configuration ([#7812](#7812)) ([3d70111](3d70111))
* **aws:** Add Method and Integration Resources for API Gateway ([#7923](#7923)) ([f3d669a](f3d669a))
* **aws:** Add New Elasticache Resources and Attributes ([#7925](#7925)) ([e18ca20](e18ca20))
* **aws:** Add New Validation for AWS Tags ([#7651](#7651)) ([2440e89](2440e89))
* **aws:** Add Support for CloudWatch Filter Subscriptions ([#8073](#8073)) ([cbc2fb1](cbc2fb1))
* **aws:** Add Support for Directconnect Locations ([#7906](#7906)) ([0187098](0187098))
* **aws:** Add Support for EC2 Managed Prefix List ([#7942](#7942)) ([743fdd2](743fdd2))
* **aws:** Add Support for Route53 Operations ([#7944](#7944)) ([306f0bd](306f0bd))
* **aws:** Step Function Resources ([#7911](#7911)) ([ffb3275](ffb3275))
* **aws:** Support Availability Zones ([#7914](#7914)) ([f082057](f082057))


### Bug Fixes

* **aws:** Add `account_id` and `region` to `aws_appstream_images` PK ([#7972](#7972)) ([a7cfd33](a7cfd33))
* **aws:** Add `account_id` and `region` to `aws_ec2_transit_gateways` PK ([#8060](#8060)) ([37fbf63](37fbf63))
* **aws:** Add `account_id` and `region` to PK in `aws_directconnect_gateways` ([#7984](#7984)) ([588bc88](588bc88))
* **aws:** Add `account_id` and region to `aws_quicksight_*` resources ([4d0fdb4](4d0fdb4))
* **aws:** Add `request_account_id` & `request_region` to `aws_securityhub_findings` PK ([#7971](#7971)) ([aa74371](aa74371))
* **aws:** Add `resource_share_arn` and `region` to `aws_ram_principals` PK ([#7985](#7985)) ([fd24a5b](fd24a5b))
* **aws:** Add parent table ARNs as PKs to child tables for `aws_resiliencehub_*` resources ([2f70712](2f70712))
* **aws:** Fix `aws_iam_accounts` unmarshaling ([#7899](#7899)) ([abf28ed](abf28ed))
* **aws:** Fix PK  for `aws_rds_certificates` ([#7817](#7817)) ([8082b2a](8082b2a))
* **aws:** PK for `aws_docdb_certificates` ([#7820](#7820)) ([b2b06ea](b2b06ea))
* **aws:** PK for `aws_ec2_images` ([#7821](#7821)) ([d568cde](d568cde))
* **aws:** PK for `aws_s3_bucket_grants` ([#7822](#7822)) ([4efbf32](4efbf32))
* **aws:** Remove `account_id` and `region` columns from `aws_resiliencehub_*` PKs ([2f70712](2f70712))
* **aws:** Rename `user_arn` field to `arn` in `aws_quicksight_group_members` ([4d0fdb4](4d0fdb4))
* **aws:** Resource Access Manager (RAM) PK issues ([#8010](#8010)) ([901dcf4](901dcf4))
* **aws:** Use `log_group_arn` + `filter_name` for `aws_cloudwatchlogs_metric_filters` PK ([#8061](#8061)) ([d29f19a](d29f19a))
* **aws:** Use `physical_resource_identifier` instead of `physical_resource_id` in `aws_resiliencehub_app_version_resources` and `aws_resiliencehub_app_version_resource_mappings` PKs ([2f70712](2f70712))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/codepipeline to v1.14.1 ([#7945](#7945)) ([bd1eee8](bd1eee8))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/cognitoidentity to v1.15.1 ([#7946](#7946)) ([7747eab](7747eab))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider to v1.22.1 ([#7947](#7947)) ([f3307f2](f3307f2))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/configservice to v1.29.2 ([#7948](#7948)) ([db7b7af](db7b7af))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/databasemigrationservice to v1.23.2 ([#7949](#7949)) ([ff3e2d1](ff3e2d1))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/dax to v1.12.1 ([#7950](#7950)) ([3127200](3127200))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/directconnect to v1.18.2 ([#7951](#7951)) ([c220d49](c220d49))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/docdb to v1.20.2 ([#7952](#7952)) ([f021f80](f021f80))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/dynamodb to v1.18.2 ([#7953](#7953)) ([b50cb36](b50cb36))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/ecr to v1.18.2 ([#7954](#7954)) ([610165a](610165a))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/ecrpublic to v1.15.1 ([#7955](#7955)) ([70a2b8b](70a2b8b))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/ecs to v1.23.2 ([#7956](#7956)) ([66b4cee](66b4cee))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/efs to v1.19.3 ([#7957](#7957)) ([202d467](202d467))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/eks to v1.27.2 ([#7958](#7958)) ([8f08e65](8f08e65))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/elasticache to v1.26.2 ([#7959](#7959)) ([4ca09b8](4ca09b8))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk to v1.15.1 ([#7960](#7960)) ([e859fd0](e859fd0))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing to v1.15.2 ([#7961](#7961)) ([d7b1163](d7b1163))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 to v1.19.3 ([#7962](#7962)) ([4afa209](4afa209))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/elasticsearchservice to v1.18.2 ([#7963](#7963)) ([69752f3](69752f3))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/elastictranscoder to v1.14.1 ([#7964](#7964)) ([d8ca305](d8ca305))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/emr to v1.22.2 ([#7965](#7965)) ([1ee800c](1ee800c))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/firehose to v1.16.2 ([#7966](#7966)) ([48a4faf](48a4faf))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/fsx to v1.28.2 ([#7967](#7967)) ([2ff2fce](2ff2fce))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/glacier to v1.14.2 ([#7968](#7968)) ([0a5fe22](0a5fe22))
* **deps:** Update module github.com/aws/aws-sdk-go-v2/service/guardduty to v1.17.2 ([#7969](#7969)) ([7fcb80a](7fcb80a))
* **deps:** Update module github.com/cloudquery/codegen to v0.2.1 ([#7875](#7875)) ([9d10ac1](9d10ac1))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.36.0 ([#7809](#7809)) ([c85a9cb](c85a9cb))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.36.1 ([#7930](#7930)) ([39dccc1](39dccc1))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.37.0 ([#7933](#7933)) ([dc9cffb](dc9cffb))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.37.1 ([#8008](#8008)) ([c47aac0](c47aac0))
* Fix ECR image ARN to use repository name ([#7839](#7839)) ([e585d61](e585d61))
* Update endpoints ([#7795](#7795)) ([7f5260c](7f5260c))
* Update endpoints ([#7797](#7797)) ([3e72d3e](3e72d3e))
* Update endpoints ([#7798](#7798)) ([0a21b16](0a21b16))
* Update endpoints ([#7799](#7799)) ([ea62bbc](ea62bbc))
* Update endpoints ([#7810](#7810)) ([c797331](c797331))
* Update endpoints ([#7811](#7811)) ([5b1566c](5b1566c))
* Update endpoints ([#7816](#7816)) ([e1cca0c](e1cca0c))
* Update endpoints ([#7991](#7991)) ([3e81234](3e81234))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants