modifyMountTargetSecurityGroups method

Future<void> modifyMountTargetSecurityGroups({
  1. required String mountTargetId,
  2. List<String>? securityGroups,
})

Modifies the set of security groups in effect for a mount target.

When you create a mount target, Amazon EFS also creates a new network interface. For more information, see CreateMountTarget. This operation replaces the security groups in effect for the network interface associated with a mount target, with the SecurityGroups provided in the request. This operation requires that the network interface of the mount target has been created and the lifecycle state of the mount target is not deleted.

The operation requires permissions for the following actions:

  • elasticfilesystem:ModifyMountTargetSecurityGroups action on the mount target's file system.
  • ec2:ModifyNetworkInterfaceAttribute action on the mount target's network interface.

May throw BadRequest. May throw InternalServerError. May throw MountTargetNotFound. May throw IncorrectMountTargetState. May throw SecurityGroupLimitExceeded. May throw SecurityGroupNotFound.

Parameter mountTargetId : The ID of the mount target whose security groups you want to modify.

Parameter securityGroups : An array of up to five VPC security group IDs.

Implementation

Future<void> modifyMountTargetSecurityGroups({
  required String mountTargetId,
  List<String>? securityGroups,
}) async {
  ArgumentError.checkNotNull(mountTargetId, 'mountTargetId');
  _s.validateStringLength(
    'mountTargetId',
    mountTargetId,
    13,
    45,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    if (securityGroups != null) 'SecurityGroups': securityGroups,
  };
  await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/2015-02-01/mount-targets/${Uri.encodeComponent(mountTargetId)}/security-groups',
    exceptionFnMap: _exceptionFns,
  );
}