-
Notifications
You must be signed in to change notification settings - Fork 437
Closed as not planned
Labels
Description
Is your feature request related to a problem? Please describe.
When using the STS AssumeRole
API to perform tasks in the context of another IAM role, there is usually a lot of boilerplate code to write:
credentials = sts.assume_role(RoleArn="...", "RoleSessionName="...")["Credentials"]
ec2 = boto3.Session(aws_session_token=credentials["SessionToken"], ...).client("ec2")
This feature request is about adding a new small helper utility for switching roles during Lambda invocations easier.
Describe the solution you'd like
A contextmanager for assuming a session for given context, something like
from aws_lambda_powertools.utilities import scoped_session
with scoped_session("ec2", role_arn="<role-arn>") as ec2:
ec2.describe_regions()
Describe alternatives you've considered
Maybe there is also the possibility to do this using a decorator but I have no good API design for that.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Closed