def lookup_s3_tags()

in access-analyzer/step-functions-archive-findings/functions/context-enrichment/app.py [0:0]


def lookup_s3_tags(bucket_name):
  s3_client = boto3.client("s3")
  bucket_tags=[]
  try:
    bucket_tags = s3_client.get_bucket_tagging(Bucket=bucket_name)["TagSet"]

    for tags in bucket_tags:
      tags[tags.pop("Key")]=tags.pop("Value")
  except ClientError:
    #https://github.com/boto/boto3/issues/341
    logger.exception(f"Error retrieving tags for S3 bucket {bucket_name}")

  return dict(ChainMap(*bucket_tags))