STS 代入角色的临时凭证有效性

Validity of temp credentials by STS Assume role

我正在调用 AWS 中的 boto 函数来担任角色。我能够获得临时凭据,但这些凭据的最长有效期为 1 小时。有什么方法可以承担角色,临时凭证至少应在 4 小时内有效。下面是我正在使用的代码片段

    client = boto3.client('sts')
    response = client.assume_role(RoleArn=<Role ARN Name>,RoleSessionName=<Name of Session>)

然后我使用从响应中获得的凭据

使用assume_role可以获得的最大有效期为3600秒。 如果您有 IAM 用户凭证,请考虑使用 get_session_token

By default, temporary security credentials for an IAM user are valid for a maximum of 12 hours, but you can request a duration as short as 15 minutes or as long as 36 hours. For security reasons, a token for an AWS account's root identity is restricted to a duration of one hour.

有关不同 STS API 选项的凭证生命周期,请参阅此 doc