def CopyEBSSnapshotToS3(
    s3_destination: str,
    snapshot_id: str,
    instance_profile_name: str,
    zone: str,
    subnet_id: Optional[str] = None,
    security_group_id: Optional[str] = None,
    cleanup_iam: bool = False
    ) -> Dict[str, Any]:
  """Copy an EBS snapshot into S3.

  Unfortunately, this action is not natively supported in AWS, so it requires
  creating a volume and attaching it to an instance. This instance, using a
  userdata script then performs a `dd` operation to send the disk image to S3.

  Uses the components methods of SetUp, Process and TearDown. If you want to
  copy multiple snapshots, consider using those methods directly.

  Args:
    s3_destination (str): S3 directory in the form of s3://bucket/path/folder
    snapshot_id (str): EBS snapshot ID.
    instance_profile_name (str): The name of an existing instance profile to
      attach to the instance, or to create if it does not yet exist.
    zone (str): AWS Availability Zone the instance will be launched in.
    subnet_id (str): Optional. The subnet to launch the instance in.
    security_group_id (str): Optional. Security group ID to attach.
    cleanup_iam (bool): If we created IAM components, remove them afterwards

  Raises:
    ResourceCreationError: If any dependent resource could not be created.
    ResourceNotFoundError: If the snapshot ID cannot be found.
  """
  aws_account = account.AWSAccount(zone)

  iam_details = CopyEBSSnapshotToS3SetUp(aws_account, instance_profile_name)

  # Instance role creation has a propagation delay between creating in IAM and
  # being usable in EC2.
  if iam_details['profile']['created']:
    sleep(20)

  outputs = CopyEBSSnapshotToS3Process(aws_account,
    s3_destination,
    snapshot_id,
    iam_details['profile']['arn'],
    subnet_id,
    security_group_id)

  if cleanup_iam:
    CopyEBSSnapshotToS3TearDown(aws_account, instance_profile_name, iam_details)

  return outputs
Copy an EBS snapshot into S3.

Unfortunately, this action is not natively supported in AWS, so it requires
creating a volume and attaching it to an instance. This instance, using a
userdata script then performs a `dd` operation to send the disk image to S3.

Uses the components methods of SetUp, Process and TearDown. If you want to
copy multiple snapshots, consider using those methods directly.

Args:
s3_destination (str): S3 directory in the form of s3://bucket/path/folder
snapshot_id (str): EBS snapshot ID.
instance_profile_name (str): The name of an existing instance profile to
attach to the instance, or to create if it does not yet exist.
zone (str): AWS Availability Zone the instance will be launched in.
subnet_id (str): Optional. The subnet to launch the instance in.
security_group_id (str): Optional. Security group ID to attach.
cleanup_iam (bool): If we created IAM components, remove them afterwards

Raises:
ResourceCreationError: If any dependent resource could not be created.
ResourceNotFoundError: If the snapshot ID cannot be found.
libcloudforensics/providers/aws/forensics.py