  def CreateBucket(
      self,
      name: str,
      region: Optional[str] = None,
      acl: str = 'private',
      tags: Optional[Dict[str, str]] = None,
      policy: Optional[str] = None) -> Dict[str, Any]:
    """Create an S3 storage bucket.

    Args:
      name (str): The name of the bucket.
      region (str): Optional. The region in which the bucket resides.
      acl (str): Optional. The canned ACL with which to create the bucket.
        Default is 'private'.
      tags (Dict[str, str]): Optional. A dictionary of tags to add to the
        bucket, for example {'TagName': 'TagValue'}.
      policy (str): Optional. A bucket policy to be applied after creation.
        It must be a valid JSON document.
    Appropriate values for the Canned ACLs are here:
    https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl  # pylint: disable=line-too-long

    New tags will not be set if the bucket already exists.

    Returns:
      Dict: An API operation object for a S3 bucket.
        https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Bucket.create  # pylint: disable=line-too-long

    Raises:
      ResourceCreationError: If the bucket couldn't be created or already exists.  # pylint: disable=line-too-long
    """

    client = self.aws_account.ClientApi(common.S3_SERVICE)
    try:
      desired_region = region or self.aws_account.default_region
      if desired_region == 'us-east-1':
        bucket = client.create_bucket(
            Bucket=name,
            ACL=acl)  # type: Dict[str, Any]
      else:
        bucket = client.create_bucket(
            Bucket=name,
            ACL=acl,
            CreateBucketConfiguration={
                'LocationConstraint': desired_region
            })
    except client.exceptions.BucketAlreadyOwnedByYou as exception:
      raise errors.ResourceCreationError(
          'Bucket {0:s} already exists: {1:s}'.format(
              name, str(exception)),
          __name__) from exception
    except client.exceptions.ClientError as exception:
      raise errors.ResourceCreationError(
          'Could not create bucket {0:s}: {1:s}'.format(
              name, str(exception)),
          __name__) from exception
    logger.info('Bucket successfully created')

    if tags:
      bucket_tags = {'TagSet': []}  # type: Dict[str, List[Dict[str, str]]]
      for k, v in tags.items():
        bucket_tags['TagSet'].append({'Key': k, 'Value': v})
      try:
        client.put_bucket_tagging(Bucket=name, Tagging=bucket_tags)
        logger.info('Tags successfully set')
      except client.exceptions.ClientError as exception:
        logger.warning(
            'Error while setting tags: {0:s} - {1:s}'.format(
                exception.response['Error'].get('Code', ''),
                exception.response['Error'].get('Message', '')))

    if policy:
      try:
        client.put_bucket_policy(Bucket=name, Policy=policy)
        logger.info('Policy successfully set')
      except client.exceptions.ClientError as exception:
        logger.warning(
            'Error while setting policy: {0:s} - {1:s}'.format(
                exception.response['Error'].get('Code', ''),
                exception.response['Error'].get('Message', '')))

    return bucket
Create an S3 storage bucket.

Args:
name (str): The name of the bucket.
region (str): Optional. The region in which the bucket resides.
acl (str): Optional. The canned ACL with which to create the bucket.
Default is 'private'.
tags (Dict[str, str]): Optional. A dictionary of tags to add to the
bucket, for example {'TagName': 'TagValue'}.
policy (str): Optional. A bucket policy to be applied after creation.
It must be a valid JSON document.
Appropriate values for the Canned ACLs are here:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl  # pylint: disable=line-too-long

New tags will not be set if the bucket already exists.

Returns:
Dict: An API operation object for a S3 bucket.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Bucket.create  # pylint: disable=line-too-long

Raises:
ResourceCreationError: If the bucket couldn't be created or already exists.  # pylint: disable=line-too-long
libcloudforensics/providers/aws/internal/s3.py