I am able to manually assume role using AWS console but while assuming role using boto3 getting access denied error |
sts_client = boto3.client('sts')
assumed_role = sts_client.assume_role(
RoleArn=aws_src_role_arn,
RoleSessionName='AssumeRoleSession')
I tried using lambda and python code as well but facing the same issue in both
When you assume a role with a call to STS, you get the temporary credentials in response. You need to construct an additional client or resource using those credentials because the default client uses the original lambda's role credentials. Excerpt from AWS documentation with code examples: