You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The credentials from STS assume role has a duration. Moreover, if using role chaining (using one role to assume a different role), AWS cap the duration at 1 hr. link.
In our use case, we are using AWS SageMaker with a role, then within an R session, we assume a second role to access Athena. However, after 1 hour, the connection expires. To refresh the credentials and restore the connection, I need to re-run assume_role and DBI::dbConnect. While this works to create new tables or queries using the refreshed credentials, I cannot reference any lazy tbl objects that were created using the expired connection, even after refreshing the connection and credentials. As I inspect the lazy tbl object, the ptr in con is unchanged and still pointing to the connection expired.
Is there a workaround for this?
Reprex
library(RAthena)
library(DBI)
library(dbplyr)
crd<-RAthena::assume_role(role_arn="arn:aws:sts::123456789012:assumed-role/role_name/role_session_name"set_env=FALSE,
duration=3600L# the maximum
)
con<-DBI::dbConnect(
RAthena::athena(),
aws_access_key_id=crd$AccessKeyId,
aws_secret_access_key=crd$SecretAccessKey,
aws_session_token=crd$SessionToken
)
my_iris<- tbl(con, sql("SELECT * FROM iris"))
my_iris# after 1 hr# Refresh credentials and connectioncrd<-RAthena::assume_role(role_arn="arn:aws:sts::123456789012:assumed-role/role_name/role_session_name"set_env=FALSE,
duration=3600L# the maximum
)
con<-DBI::dbConnect(
RAthena::athena(),
aws_access_key_id=crd$AccessKeyId,
aws_secret_access_key=crd$SecretAccessKey,
aws_session_token=crd$SessionToken
)
# this worksmy_iris_new<- tbl(con, sql("SELECT * FROM iris"))
my_iris_new# this doesn't workmy_iris# credentials expired error
The text was updated successfully, but these errors were encountered:
The credentials from STS assume role has a duration. Moreover, if using role chaining (using one role to assume a different role), AWS cap the duration at 1 hr. link.
In our use case, we are using AWS SageMaker with a role, then within an R session, we assume a second role to access Athena. However, after 1 hour, the connection expires. To refresh the credentials and restore the connection, I need to re-run assume_role and DBI::dbConnect. While this works to create new tables or queries using the refreshed credentials, I cannot reference any lazy tbl objects that were created using the expired connection, even after refreshing the connection and credentials. As I inspect the lazy tbl object, the ptr in con is unchanged and still pointing to the connection expired.
Is there a workaround for this?
Reprex
The text was updated successfully, but these errors were encountered: