Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Cross account access using table ARN with query #850

Open
mzientkowski opened this issue Jan 14, 2025 · 1 comment
Open

AWS Cross account access using table ARN with query #850

mzientkowski opened this issue Jan 14, 2025 · 1 comment

Comments

@mzientkowski
Copy link

Version: 3.10.0

Issue: Querying GSI with AWS Cross-Account Access in Dynamoid Uses Table Name Instead of Table ARN

Description

When querying a Global Secondary Index (GSI) in Dynamoid using AWS cross-account access, the library builds the query using the table name instead of the table ARN. This behavior causes issues since the correct ARN is required for cross-account access.

Example Code

class Offer
  include Dynamoid::Document

  table name: 'arn:aws:dynamodb:eu-west-1:123559793147:table/offers', key: :join_id, capacity_mode: :on_demand
  field :shop_id, :string
  field :sanitized_link, :string

  global_secondary_index name: :shop_id_sanitized_link,
                         hash_key: :shop_id, range_key: :sanitized_link, projected_attributes: :all
end

Steps to Reproduce

This works correctly since the table ARN is used under the hood.

Offer.find('join_id')

Attempt to query a GSI. The generated query uses the table name (offers) instead of the table ARN.

Offer.where(shop_id: 'shop_id', sanitized_url: 'sanitized_url').with_index(:shop_id_sanitized_link).first

Workaround

I implemented a monkey patch to resolve the issue temporarily:

class Dynamoid::AdapterPlugin::AwsSdkV3::Table
  def name
    schema[:table_arn]
  end
end
@andrykonchin
Copy link
Member

Thank you reporting the issue! I will look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants