Policy examples for network access
The following examples show how to allow or deny access to S3 file systems by network path. To use these examples, replace the Region, account IDs, file system IDs, and principal ARNs with your own values. For descriptions of the actions and condition keys used in these examples, see Permissions for S3 Files Endpoints. Access through S3 Files Endpoints requires each client action under both the s3files and s3files-endpoint IAM names. The examples that grant access through S3 Files Endpoints therefore list each client action twice.
Example 1: Grant full access through S3 Files Endpoints and VPC mount targets
The following identity policy allows a principal to mount a file system with read, write, and root access through either network path.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowFullAccessBothPaths", "Effect": "Allow", "Action": [ "s3files:CreateMountSession", "s3files:ClientMount", "s3files:ClientWrite", "s3files:ClientRootAccess", "s3files-endpoint:ClientMount", "s3files-endpoint:ClientWrite", "s3files-endpoint:ClientRootAccess" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0" } ] }
Example 2: Grant read-only access through both network paths
The following identity policy allows a principal to mount a file system with read-only access. It omits the ClientWrite actions, so the client can't modify data.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowReadOnlyBothPaths", "Effect": "Allow", "Action": [ "s3files:CreateMountSession", "s3files:ClientMount", "s3files-endpoint:ClientMount" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0" } ] }
Example 3: Allow a principal to connect only through S3 Files Endpoints
The following file system policy grants read and write access to a role, but only through S3 Files Endpoints. Without the condition in the first statement, the s3files actions would also allow the role to connect through a VPC mount target. The second statement grants the CreateMountSession action that the mount helper uses. It has no condition because the network path condition keys don't apply to that action.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "EndpointOnlyAccess", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/AgentSessionRole" }, "Action": [ "s3files:ClientMount", "s3files:ClientWrite", "s3files-endpoint:ClientMount", "s3files-endpoint:ClientWrite" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0", "Condition": { "Bool": { "s3files:AccessedViaRegionalEndpoint": "true" } } }, { "Sid": "AllowMountSession", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/AgentSessionRole" }, "Action": [ "s3files:CreateMountSession" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0" } ] }
Example 4: Grant full access in a VPC and read-only access through S3 Files Endpoints
The following file system policy grants full access through VPC mount targets and read-only access through S3 Files Endpoints. Because ClientRootAccess is granted only when AccessedViaMountTarget is true, root access isn't available through S3 Files Endpoints.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VpcFullAccess", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/AppRole" }, "Action": [ "s3files:ClientMount", "s3files:ClientWrite", "s3files:ClientRootAccess" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0", "Condition": { "Bool": { "s3files:AccessedViaMountTarget": "true" } } }, { "Sid": "EndpointReadOnly", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/AgentSessionRole" }, "Action": [ "s3files:ClientMount", "s3files-endpoint:ClientMount" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0", "Condition": { "Bool": { "s3files:AccessedViaRegionalEndpoint": "true" } } } ] }
Example 5: Grant cross-account access through S3 Files Endpoints
The following file system policy allows a role in account 444455556666 to mount the file system through S3 Files Endpoints. The second statement allows the role to call CreateMountSession on this file system. It has no condition because the network path condition keys don't apply to that action. The role also needs an identity policy in account 444455556666 that grants the same actions on this file system.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowCrossAccountEndpointAccess", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::444455556666:role/AgentRuntimeRole" }, "Action": [ "s3files:ClientMount", "s3files:ClientWrite", "s3files-endpoint:ClientMount", "s3files-endpoint:ClientWrite" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0", "Condition": { "Bool": { "s3files:AccessedViaRegionalEndpoint": "true" } } }, { "Sid": "AllowCrossAccountMountSession", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::444455556666:role/AgentRuntimeRole" }, "Action": "s3files:CreateMountSession", "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0" } ] }
Example 6: Deny all access through S3 Files Endpoints
The following statement denies every action in the s3files-endpoint IAM name. It restricts access to VPC mount targets with one statement and no condition keys. The statement uses a wildcard so that it denies all access through S3 Files Endpoints, and it applies even if you later attach a broader allow policy. The client can still call CreateMountSession, but S3 Files rejects the connection. To also deny the CreateMountSession call, add a statement that denies s3files:CreateMountSession. You can use this statement in a file system policy, an identity policy, or a service control policy (SCP). As an SCP, it denies access through S3 Files Endpoints to all S3 file systems in every account where you attach it. The following example shows it as a file system policy.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyEndpointAccess", "Effect": "Deny", "Principal": "*", "Action": "s3files-endpoint:*", "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0" } ] }
Example 7: Deny access through S3 Files Endpoints with a condition key
The following file system policy denies access through S3 Files Endpoints by using the s3files client actions and the AccessedViaRegionalEndpoint condition key. Use this form when you manage network path controls with condition keys across your policies.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyAnyEndpointAccess", "Effect": "Deny", "Principal": "*", "Action": [ "s3files:ClientMount", "s3files:ClientWrite", "s3files:ClientRootAccess" ], "Resource": "arn:aws:s3files:us-east-1:111122223333:file-system/fs-0123456789abcdef0", "Condition": { "Bool": { "s3files:AccessedViaRegionalEndpoint": "true" } } } ] }