def InstanceNetworkQuarantine(
    zone: str,
    instance_id: str,
    exempted_src_subnets: Optional[List[str]] = None
    ) -> None:
  """Put an AWS EC2 instance in network quarantine.

  Network quarantine is imposed via applying empty security groups to the
  instance.

  Args:
    zone (str): AWS Availability Zone the instance is in.
    instance_id (str): The id (i-xxxxxx) of the virtual machine.
    exempted_src_subnets (List[str]): List of subnets that will be permitted

  Raises:
    ResourceNotFoundError: If the instance cannot be found.
    ResourceCreationError: If the security group could not be created.
    AddressValueError: If a provided subnet is invalid.
  """
  # Add /32 to any specified subnets that don't have a mask
  # We're not checking the subnet is well formed, CreateIsolationSecurityGroup
  # will take care of that
  if exempted_src_subnets:
    exempted_src_subnets[:] = [subnet if '/' in subnet else subnet + '/32'
      for subnet in exempted_src_subnets]

  try:
    aws_account = account.AWSAccount(zone)
    vpc = aws_account.ec2.GetInstanceById(instance_id).vpc
    logger.info('Creating isolation security group')
    sg_id = \
      aws_account.ec2.CreateIsolationSecurityGroup(vpc, exempted_src_subnets)
    logger.info('Replacing attached security groups with isolation group')
    aws_account.ec2.SetInstanceSecurityGroup(instance_id, sg_id)
  except errors.ResourceNotFoundError as exception:
    raise errors.ResourceNotFoundError(
      'Cannot qurantine non-existent instance {0:s}: {1!s}'.format(instance_id,
        exception), __name__) from exception
Put an AWS EC2 instance in network quarantine.

Network quarantine is imposed via applying empty security groups to the
instance.

Args:
zone (str): AWS Availability Zone the instance is in.
instance_id (str): The id (i-xxxxxx) of the virtual machine.
exempted_src_subnets (List[str]): List of subnets that will be permitted

Raises:
ResourceNotFoundError: If the instance cannot be found.
ResourceCreationError: If the security group could not be created.
AddressValueError: If a provided subnet is invalid.
libcloudforensics/providers/aws/forensics.py