Repository navigation
Support assume-role for Glue and DynamoDB catalogs - #4132
David-Banquet wants to merge 3 commits into
Conversation
Extend the existing S3 FileIO assume-role mechanism (client.role-arn / client.role-session-name) to the boto3 sessions built by GlueCatalog and DynamoDbCatalog. When a role ARN is configured, an STS AssumeRole is performed from the base session and the resulting temporary credentials are used for the Glue/DynamoDB client. Role configuration follows the same precedence already used for the other client.* properties: a service-prefixed override (glue.role-arn / dynamodb.role-arn, glue.role-session-name / dynamodb.role-session-name) falls back to the unified client.role-arn / client.role-session-name. Default behavior (no role ARN configured) is unchanged. Closes apache#2747 Signed-off-by: lemon0333 <147061193+lemon0333@users.noreply.github.com>
The catalog session was built from the static credentials of a single AssumeRole call, so a long-lived catalog failed with ExpiredToken once the role session ended (one hour by default). Use botocore's AssumeRoleCredentialFetcher with DeferredRefreshableCredentials: the role is assumed on first use and again before the credentials expire. Co-authored-by: lemon0333 <147061193+lemon0333@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fokko
left a comment
There was a problem hiding this comment.
Thanks for adding this @David-Banquet I've left a small comment
| | client.role-session-name | session | An optional identifier for the assumed role session. | | ||
| | client.role-arn | arn:aws:... | AWS Role ARN. If provided instead of access_key and secret_key, temporary credentials will be fetched by assuming this role. | | ||
| | client.role-session-name | session | An optional identifier for the assumed role session used to access both the Glue/DynamoDB Catalog and the S3 FileIO. | | ||
| | client.role-arn | arn:aws:... | AWS Role ARN. If provided instead of access_key and secret_key, temporary credentials will be fetched by assuming this role before accessing both the Glue/DynamoDB Catalog and the S3 FileIO. | |
There was a problem hiding this comment.
The order is different here. Can we first do arn, and then role-session-name?
I've checked against the Java implementation, and there we use client.assume-role.arn and client.assume-role.session-name. Can we use the same keys here? This way when this information is supplied through a catalog, then it works for both.
There was a problem hiding this comment.
Thanks, done in ccd5aaa. The table now lists client.assume-role.arn first, then client.assume-role.session-name.
client.role-arn and client.role-session-name already existed for the S3 FileIO, with s3.role-arn / s3.role-session-name as overrides, so I kept them as a fallback. The catalogs and the S3 FileIO now read client.assume-role.* first, then client.role-*. A catalog that passes the Java keys covers both, and existing configs keep working. The glue.role-* and dynamodb.role-* overrides follow the s3.role-* pattern.
Should the client.role-* keys also get a deprecation warning, or stay as aliases?
Java uses client.assume-role.arn and client.assume-role.session-name. The Glue and DynamoDB catalogs and the S3 FileIO now read them first, so the same properties work for both when a catalog passes them. The existing client.role-arn / client.role-session-name keys stay as a fallback, and the service-prefixed overrides keep their precedence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #2747
Rationale for this change
This picks up #3838 by @lemon0333, which was closed for inactivity before anyone reviewed it (see my comment there). Their commit is kept as is, with them as author.
client.role-arn/client.role-session-nameare honored by the S3 FileIO but ignored by the Glue and DynamoDB catalogs, which build their ownboto3.Session. #3838 extends them to both catalogs, with service-prefixed overrides (glue.role-arn,dynamodb.role-arn, and the matching*-role-session-name) falling back to theclient.*ones, like the other session properties.The second commit changes one thing: #3838 built the catalog session from the static credentials of a single
AssumeRolecall, so a long-lived catalog started failing withExpiredTokenonce the role session ended (one hour by default). The session now uses botocore'sAssumeRoleCredentialFetcherwithDeferredRefreshableCredentials: the role is assumed on first use and again before the credentials expire, the same way botocore handlesrole_arnin an AWS profile.Are these changes tested?
Yes, with
moto:Are there any user-facing changes?
Yes: the Glue and DynamoDB catalogs now honor
client.role-arn/client.role-session-name, plus the newglue.role-arn,glue.role-session-name,dynamodb.role-arnanddynamodb.role-session-name. Documented inconfiguration.md. Nothing changes when no role ARN is set.🤖 Generated with Claude Code