Accessing QLDB ledger in another AWS account

230 Views Asked by At

I'm having trouble accessing the QLDB ledger in another AWS account.

I have granted necessary IAM permission for cross-account access.

I set the credentials in the EC2 where my python script is runing using below code.

sts_client = boto3.client("sts", region_name=region)
response = sts_client.assume_role(
    RoleArn="arn:aws:iam::xxx:role/xxx-ec2",
    RoleSessionName="RoleSessionname",
)

os.environ["AWS_ACCESS_KEY_ID"] = response["Credentials"]["AccessKeyId"]
os.environ["AWS_SECRET_ACCESS_KEY"] = response["Credentials"]["SecretAccessKey"]
os.environ["AWS_SESSION_TOKEN"] = response["Credentials"]["SessionToken"]
os.environ["AWS_DEFAULT_REGION"] = region

but keep on getting below error

in _get_session
    raise ExecuteError(e, True, True)
pyqldb.errors.ExecuteError: Error containing the context of a failure during execute.

botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the SendCommand operation: The Ledger with name my-ledger is not found

the error is thrown during the execution of the below code.

qldb_driver = QldbDriver(ledger_name='my-ledger', region_name='us-east-1')
result = qldb_driver.execute_lambda(lambda x: read_table(x, table_name))
1

There are 1 best solutions below

1
On

Found out that the credentials can be passed to QldbDriver function per -> https://github.com/awslabs/amazon-qldb-driver-python/blob/master/pyqldb/driver/qldb_driver.py#L103