I'm trying to connect to Amazon Keyspaces leveraging the Assume role provider
which refreshes the credentials the moment they expire. I've set up my aws config file as the documentation states
[profile cassandra]
role_arn=role_to_assume
source_profile=default
role_session_name=testingCassandraConnection
duration_seconds=900
then, within the code I start a session with that profile
boto_session = boto3.Session(profile_name='cassandra', region_name='us-east-1')
auth_provider = SigV4AuthProvider(boto_session)
cluster = Cluster(
[CASSANDRA_CLUSTER],
ssl_context=ssl_context,
auth_provider=auth_provider,
port=9142
)
session = cluster.connect()
but I get the error Error from server: code=0100 [Bad credentials] message="Authentication failure: SessionId mismatch
I also tried using sts_client.assume_role
and passing the credentials directly to boto3.Session()
and it works this way but I won't be able to refresh credentials when they expire.
has anyone encountered this problem?