def GenerateUniqueInstanceName(
    prefix: str, truncate_at: Optional[int] = None) -> str:
  """Add a timestamp as a suffix to provided name and truncate at max limit.

  Args:
    prefix (str): The name prefix to add the timestamp to and truncate.
    truncate_at (int): Optional. The maximum length of the generated name.
        Default no limit.

  Returns:
    str: The name after adding a timestamp.
        Ex: [prefix]-[rand]-[TIMESTAMP('%Y%m%d%H%M%S')]
  """
  rand = ''.join(random.choices(string.ascii_lowercase, k=5))
  timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
  if truncate_at:
    prefix = prefix[:(truncate_at - len(timestamp) - 7)]
  name = f'{prefix}-{rand}-{timestamp}'
  return name
Add a timestamp as a suffix to provided name and truncate at max limit.

Args:
prefix (str): The name prefix to add the timestamp to and truncate.
truncate_at (int): Optional. The maximum length of the generated name.
Default no limit.

Returns:
str: The name after adding a timestamp.
Ex: [prefix]-[rand]-[TIMESTAMP('%Y%m%d%H%M%S')]
libcloudforensics/providers/gcp/internal/common.py