How to Limit AWS Agent Access With STS GetScopedCredentials

An agent that reads a report from Amazon S3 may only need access to one prefix for a few minutes. AWS Security Token Service (STS) offers GetScopedCredentials to derive credentials for that task from an existing temporary AWS session. The new credentials keep the caller’s IAM identity and can have fewer permissions, a shorter lifetime or both. AWS Security Blog

Start with a temporary session that explicitly allows sts:GetScopedCredentials and use a Regional STS endpoint. Define an inline policy for the actions and resources the task needs. For example, give a report reader s3:GetObject for the required S3 prefix. The resulting permissions are those that both the original session and the new policy allow. The inline policy can be up to 2,048 characters, and the requested lifetime cannot exceed the time left in the original session. AWS STS API reference · AWS IAM guide

Pass the narrower credentials to the agent. A short task description appears in the CloudTrail event for credential issuance. The access key ID in subsequent logged requests can help trace them back to that event. Before deployment, test that the intended task succeeds and an out-of-scope request fails.

Latest articles

Related articles