Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 62 additions & 3 deletions docs/concepts/assumerole.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ AssumeRole

The only required parameter for the ``AssumeRole`` object is ``RoleArn``.
All other parameters are completely optional.
.. warning::

.. warning::

Although you *may* provide ``TokenCode`` for MFA, **this is not recommended**.
You will need to edit your config every time your MFA token changes, which is roughly every 30 seconds.
Expand Down Expand Up @@ -38,4 +38,63 @@ The ``AssumeRole`` object in a config represents parameters for :meth:`STS.Clien
- str
ProvidedContexts:
- ProviderArn: str
ContextAssertion: str
ContextAssertion: str

.. _assumerole-session-policies:

Session policies: ``Policy`` and ``PolicyArns``
-----------------------------------------------

``Policy`` and ``PolicyArns`` are both **session policies** — IAM policies you attach at the moment of role assumption to further restrict what the resulting session can do.

.. important::

Session policies can only **restrict** permissions, never expand them.
The effective permissions of the session are the intersection of the role's identity-based policies and the session policies you provide.
You cannot use a session policy to grant access that the role itself does not already have.

Use ``Policy`` to supply an inline JSON policy document directly in your config:

.. code-block:: yaml

AssumeRole:
RoleArn: arn:aws:iam::123456789012:role/MyRole
Policy: '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::my-bucket/*"}]}'

For readability, YAML block scalars work equally well:

.. code-block:: yaml

AssumeRole:
RoleArn: arn:aws:iam::123456789012:role/MyRole
Policy: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}

Use ``PolicyArns`` to reference one or more existing managed policies by ARN — both AWS managed and customer managed policies are supported:

.. code-block:: yaml

AssumeRole:
RoleArn: arn:aws:iam::123456789012:role/MyRole
PolicyArns:
- arn:aws:iam::aws:policy/ReadOnlyAccess
- arn:aws:iam::123456789012:policy/MyCustomPolicy

You can use both ``Policy`` and ``PolicyArns`` together. In that case, the session's effective permissions are the intersection of the role's policies with *all* provided session policies:

.. code-block:: yaml

AssumeRole:
RoleArn: arn:aws:iam::123456789012:role/MyRole
Policy: '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":"*"}]}'
PolicyArns:
- arn:aws:iam::aws:policy/ReadOnlyAccess