With the AWS CLI you can assume a role using the --profile parameter:

aws --profile <profile_name> <service> <command>


aws --profile admin s3 ls s3://mybucket/

That profile can be an AWS role that os to be assumed. My problem with that is that the session of the role is only valid for one hour by default. Is there a way of explicitly setting the session duration without using the sts service directly?


2 Answers 2


You can set a maximum duration of up to 12 hours in the IAM Role config:

enter image description here

Hope that helps.

  • Thanks, but how do you set that on the CLI?
    – Hugo G
    Sep 24, 2018 at 6:40

Along with changing the MaxSessionDuration(as mentioned in the above answer) of the IAM role ,also try adding/changing "duration_seconds" parameter value in the credentials file of the configured profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.