Assuming a role can be done using AWS CLI or SDKs. Here’s an example using AWS CLI:
aws sts assume-role --role-arn arn:aws:iam::123456789012:role/MyRole --role-session-name MySession
This returns temporary security credentials (Access Key ID, Secret Access Key, and Session Token) that can be used to access AWS resources.