Skip to content

Commit

Permalink
add tags on creation time
Browse files Browse the repository at this point in the history
  • Loading branch information
shashank2000 committed Sep 6, 2024
1 parent 2e545b8 commit 71315a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sky/data/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,19 @@ def _create_s3_bucket(self,
s3_client.create_bucket(**create_bucket_config)
logger.info(
f'Created S3 bucket {bucket_name!r} in {region or "us-east-1"}')

# add tags to the bucket
bucket_tags = skypilot_config.get_nested(('aws', 'labels'), {})
if bucket_tags:
s3_client.put_bucket_tagging(
Bucket=bucket_name,
Tagging={
'TagSet': [{
'Key': k,
'Value': v
} for k, v in bucket_tags.items()]
})

except aws.botocore_exceptions().ClientError as e:
with ux_utils.print_exception_no_traceback():
raise exceptions.StorageBucketCreateError(
Expand Down

0 comments on commit 71315a9

Please sign in to comment.