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

<p><a href="https://i.sstatic.net/d9qAj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/d9qAj.png" alt="enter image description here"></a></p>

<p>Hope that helps.</p>

CC BY-SA 4.0
2018-09-24T06:40:08.067Z
Thanks, but how do you set that on the CLI?
Hugo G
CC BY-SA 4.0
2018-09-24T04:20:14.553Z
2018-09-24T04:20:14.553Z
MLu
<p>Along with changing the  MaxSessionDuration(as mentioned in the above answer) of the IAM role ,also try adding/changing &quot;duration_seconds&quot;  parameter value in the credentials file of the configured profile.</p>

CC BY-SA 4.0
2022-03-24T17:17:40.427Z
2022-03-24T17:17:40.427Z
Kunal
<p>With the AWS CLI you can assume a role using the <code>--profile</code> parameter:</p>

<pre><code>aws --profile &lt;profile_name&gt; &lt;service&gt; &lt;command&gt;
</code></pre>

<p>e.g.:</p>

<pre><code>aws --profile admin s3 ls s3://mybucket/
</code></pre>

<p>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 <code>sts</code> service directly?</p>

CC BY-SA 4.0
2018-11-26T05:42:51.483Z
BTW, this is a feature request on the AWS CLI: https://github.com/aws/aws-cli/issues/3307
Hugo G
<amazon-web-services><aws-cli>
AWS CLI --profile with duration > 1h
Hugo G
# AWS CLI --profile with duration > 1h

(Asked by: username_0 on 2018-09-24)

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

e.g.:
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?

**Tags:** amazon-web-services, aws-cli

> **Comments:**
> **username_0**: BTW, this is a feature request on the AWS CLI: https://github.com/aws/aws-cli/issues/3307  

---

## 2 answers

### Answer by username_1 on 2018-09-24. Score: 1

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

[![enter image description here](https://i.sstatic.net/d9qAj.png)](https://i.sstatic.net/d9qAj.png)

Hope that helps.

> **Comments:**
> **username_0**: Thanks, but how do you set that on the CLI?  

---

### Answer by username_2 on 2022-03-24. Score: 0

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.


---

