boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
9.07k stars 1.87k forks source link

create dynamodb table resource from arn not name #2658

Open mdavis-xyz opened 4 years ago

mdavis-xyz commented 4 years ago

Steps to reproduce:

MWE

import boto3

dynamodb = boto3.resource('dynamodb')
table_n = dynamodb.Table('name')
table_a = dynamodb.Table(table_n.table_arn)
table_a.load()

Desired behavior

Script does not fail

Present behavior:

botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the DescribeTable operation: User: arn:aws:sts::123:abc is not authorized to perform: dynamodb:DescribeTable on resource: arn:aws:dynamodb:ap-southeast-2:123:table/arn:aws:dynamodb:ap-southeast-2:123:table/name

Impact

I'm creating dynamodb tables in one stack, then writing/reading them from Lambda functions in another stack. Currently I need to export both the ARN and name from the first stack to the second. I need the ARN to create the IAM policy for my Lambda, and then the name to pass in as an environment variable to then pass to the boto call. This is far more hastle than should be required.

swetashre commented 3 years ago

@mdavis-xyz - Thank you for your post. Boto3 resource calls the describe operation underneath. So it depends upon the service whether they are supporting arn value while doing describe operation or not. If some service doesn't support then we would have to do arn parsing on our end in order to support arn for resource. Marking it as feature request.

yogeshcfc commented 3 years ago

Hey! @mdavis-xyz @swetashre is there any update on this feature?

amotl commented 2 months ago

Hi there. We dearly need this feature, and we believe others as well, see ^1. May we humbly ask to re-prioritize to https://github.com/boto/boto3/labels/p2 again?

matejpokorny commented 1 week ago

I just tried using dynamodb.Table('some_table_arn_from_another_account') and it indeed works, so I guess that this issue can be closed.