Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2018-09-24T06:40:08.067Z
Answers: Thanks, but how do you set that on the CLI?
Answers: Hugo G
Answers: CC BY-SA 4.0
Answers: 2018-09-24T04:20:14.553Z
Answers: 2018-09-24T04:20:14.553Z
Answers: MLu
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2022-03-24T17:17:40.427Z
Answers: 2022-03-24T17:17:40.427Z
Answers: Kunal
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2018-11-26T05:42:51.483Z
Comments: BTW, this is a feature request on the AWS CLI: https://github.com/aws/aws-cli/issues/3307
Comments: Hugo G
Tags: <amazon-web-services><aws-cli>
Title: AWS CLI --profile with duration > 1h
UserDisplayName: Hugo G
ThreadText: # 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 <profile_name> <service> <command>
  
  ```
  
  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.
  
  
  ---
  
  