Assume an IAM role in aws

#aws #iam #security #bash #powershell


It is necessary to assume an IAM role in order to perform role restricted actions in AWS.

This can be performed in the AWS Management Console or with a command issued via the shell.

AWS CLI v2

aws sts assume-role --role-arn <value> --role-session-name <value>

PowerShell

$RoleARN = '<placeholder>'
$SessionName = '<placeholder>'
$Role = Use-STSRole -RoleArn $RoleARN -RoleSessionName $SessionName
Set-AWSCredential -Credential $Role.Credentials -Scope Global

#aws #iam #powershell #bash