Applies an Amazon EFS FileSystemPolicy to an Amazon EFS file system. A file system policy is an IAM resource-based policy and can contain multiple policy statements. A file system always has exactly one file system policy, which can be the default policy or an explicit policy set or updated using this API operation. EFS file system policies have a 20,000 character limit. When an explicit policy is set, it overrides the default policy. For more information about the default file system policy, see Default EFS file system policy.
EFS file system policies have a 20,000 character limit.
This operation requires permissions for the elasticfilesystem:PutFileSystemPolicy action.
Parameters:
-
file_system_id
(FileSystemId)
–
The ID of the EFS file system that you want to create or update the FileSystemPolicy for.
-
policy
(Policy)
–
The FileSystemPolicy that you're creating. Accepts a JSON formatted policy definition. EFS file system policies have a 20,000 character limit. To find out more about the elements that make up a file system policy, see Resource-based policies within Amazon EFS.
-
bypass_policy_lockout_safety_check
(Optional[BypassPolicyLockoutSafetyCheck], default:
None
)
–
(Optional) A boolean that specifies whether or not to bypass the FileSystemPolicy lockout safety check. The lockout safety check determines whether the policy in the request will lock out, or prevent, the IAM principal that is making the request from making future PutFileSystemPolicy requests on this file system. Set BypassPolicyLockoutSafetyCheck to True only when you intend to prevent the IAM principal that is making the request from making subsequent PutFileSystemPolicy requests on this file system. The default value is False.
Raises:
-
BadRequest
–
Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.
-
FileSystemNotFound
–
Returned if the specified FileSystemId value doesn't exist in the requester's Amazon Web Services account.
-
IncorrectFileSystemLifeCycleState
–
Returned if the file system's lifecycle state is not "available".
-
InternalServerError
–
Returned if an error occurred on the server side.
-
InvalidPolicyException
–
Returned if the FileSystemPolicy is malformed or contains an error such as a parameter value that is not valid or a missing required parameter. Returned in the case of a policy lockout safety check error.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_efs/_services/async_efs.py
| async def put_file_system_policy(
self,
file_system_id: "capo_efs.types.file_system_id.FileSystemId",
policy: "capo_efs.types.policy.Policy",
*,
config_overrides: Optional[AsyncEFSClientConfig] = None,
bypass_policy_lockout_safety_check: Optional[
"capo_efs.types.bypass_policy_lockout_safety_check.BypassPolicyLockoutSafetyCheck"
] = None,
) -> "capo_efs.types.file_system_policy_description.FileSystemPolicyDescription":
"""<p>Applies an Amazon EFS <code>FileSystemPolicy</code> to an Amazon EFS file system. A file system policy is an IAM resource-based policy and can contain multiple policy statements. A file system always has exactly one file system policy, which can be the default policy or an explicit policy set or updated using this API operation. EFS file system policies have a 20,000 character limit. When an explicit policy is set, it overrides the default policy. For more information about the default file system policy, see <a href="https://docs.aws.amazon.com/efs/latest/ug/iam-access-control-nfs-efs.html#default-filesystempolicy"> Default EFS file system policy</a>. </p> <note> <p>EFS file system policies have a 20,000 character limit.</p> </note> <p>This operation requires permissions for the <code>elasticfilesystem:PutFileSystemPolicy</code> action.</p>
Args:
file_system_id: <p>The ID of the EFS file system that you want to create or update the <code>FileSystemPolicy</code> for.</p>
policy: <p>The <code>FileSystemPolicy</code> that you're creating. Accepts a JSON formatted policy definition. EFS file system policies have a 20,000 character limit. To find out more about the elements that make up a file system policy, see <a href="https://docs.aws.amazon.com/efs/latest/ug/security_iam_service-with-iam.html#security_iam_service-with-iam-resource-based-policies">Resource-based policies within Amazon EFS</a>. </p>
bypass_policy_lockout_safety_check: <p>(Optional) A boolean that specifies whether or not to bypass the <code>FileSystemPolicy</code> lockout safety check. The lockout safety check determines whether the policy in the request will lock out, or prevent, the IAM principal that is making the request from making future <code>PutFileSystemPolicy</code> requests on this file system. Set <code>BypassPolicyLockoutSafetyCheck</code> to <code>True</code> only when you intend to prevent the IAM principal that is making the request from making subsequent <code>PutFileSystemPolicy</code> requests on this file system. The default value is <code>False</code>. </p>
Raises:
capo_efs.errors.bad_request.BadRequest: <p>Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.</p>
capo_efs.errors.file_system_not_found.FileSystemNotFound: <p>Returned if the specified <code>FileSystemId</code> value doesn't exist in the requester's Amazon Web Services account.</p>
capo_efs.errors.incorrect_file_system_life_cycle_state.IncorrectFileSystemLifeCycleState: <p>Returned if the file system's lifecycle state is not "available".</p>
capo_efs.errors.internal_server_error.InternalServerError: <p>Returned if an error occurred on the server side.</p>
capo_efs.errors.invalid_policy_exception.InvalidPolicyException: <p>Returned if the <code>FileSystemPolicy</code> is malformed or contains an error such as a parameter value that is not valid or a missing required parameter. Returned in the case of a policy lockout safety check error.</p>
capo_efs.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_efs.types.put_file_system_policy_request.PutFileSystemPolicyRequest]",
) -> AsyncOperationResponse[
"capo_efs.types.file_system_policy_description.FileSystemPolicyDescription"
]:
import capo_efs._operations.magnolio_api_service_v20150201.put_file_system_policy
(
output,
http_response,
) = await capo_efs._operations.magnolio_api_service_v20150201.put_file_system_policy.async_put_file_system_policy(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutFileSystemPolicy")
)
input_: capo_efs.types.put_file_system_policy_request.PutFileSystemPolicyRequest = {
"file_system_id": file_system_id,
"policy": policy,
}
if bypass_policy_lockout_safety_check is not None:
input_["bypass_policy_lockout_safety_check"] = (
bypass_policy_lockout_safety_check
)
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|