putFileSystemPolicy method

Future<FileSystemPolicyDescription> putFileSystemPolicy({
  1. required String fileSystemId,
  2. required String policy,
  3. bool? bypassPolicyLockoutSafetyCheck,
})

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. 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.

This operation requires permissions for the elasticfilesystem:PutFileSystemPolicy action.

May throw InternalServerError. May throw FileSystemNotFound. May throw InvalidPolicyException. May throw IncorrectFileSystemLifeCycleState.

Parameter fileSystemId : The ID of the EFS file system that you want to create or update the FileSystemPolicy for.

Parameter policy : The FileSystemPolicy that you're creating. Accepts a JSON formatted policy definition. To find out more about the elements that make up a file system policy, see EFS Resource-based Policies.

Parameter bypassPolicyLockoutSafetyCheck : (Optional) A flag to indicate whether to bypass the FileSystemPolicy lockout safety check. The policy lockout safety check determines whether the policy in the request will prevent the principal making the request will be locked out from making future PutFileSystemPolicy requests on the file system. Set BypassPolicyLockoutSafetyCheck to True only when you intend to prevent the principal that is making the request from making a subsequent PutFileSystemPolicy request on the file system. The default value is False.

Implementation

Future<FileSystemPolicyDescription> putFileSystemPolicy({
  required String fileSystemId,
  required String policy,
  bool? bypassPolicyLockoutSafetyCheck,
}) async {
  ArgumentError.checkNotNull(fileSystemId, 'fileSystemId');
  _s.validateStringLength(
    'fileSystemId',
    fileSystemId,
    0,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(policy, 'policy');
  final $payload = <String, dynamic>{
    'Policy': policy,
    if (bypassPolicyLockoutSafetyCheck != null)
      'BypassPolicyLockoutSafetyCheck': bypassPolicyLockoutSafetyCheck,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/2015-02-01/file-systems/${Uri.encodeComponent(fileSystemId)}/policy',
    exceptionFnMap: _exceptionFns,
  );
  return FileSystemPolicyDescription.fromJson(response);
}