dcicutils 7.11.0.1b9__py3-none-any.whl → 7.12.0.1b4__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,6 +58,10 @@ class GlacierUtils:
58
58
  self.env_key = self.key_manager.get_keydict_for_env(env_name)
59
59
  self.health_page = get_health_page(key=self.env_key, ff_env=env_name)
60
60
 
61
+ @property
62
+ def kms_key_id(self) -> str:
63
+ return self.health_page.get("s3_encrypt_key_id", "")
64
+
61
65
  @classmethod
62
66
  def is_glacier_storage_class(cls, storage_class: S3StorageClass):
63
67
  return storage_class in S3_GLACIER_CLASSES
@@ -295,6 +299,9 @@ class GlacierUtils:
295
299
  }
296
300
  if tags:
297
301
  cmu['Tagging'] = tags
302
+ if self.kms_key_id:
303
+ cmu['ServerSideEncryption'] = 'aws:kms'
304
+ cmu['SSEKMSKeyId'] = self.kms_key_id
298
305
  mpu = self.s3.create_multipart_upload(**cmu)
299
306
  mpu_upload_id = mpu['UploadId']
300
307
  except Exception as e:
@@ -381,16 +388,21 @@ class GlacierUtils:
381
388
  else:
382
389
  # Force copy the object into standard in a single operation
383
390
  copy_source = {'Bucket': bucket, 'Key': key}
384
- copy_target = {
391
+ copy_args = {
385
392
  'Bucket': bucket, 'Key': key,
386
393
  'StorageClass': storage_class,
387
394
  }
388
395
  if version_id:
389
396
  copy_source['VersionId'] = version_id
390
- copy_target['CopySourceVersionId'] = version_id
397
+ copy_args['CopySourceVersionId'] = version_id
391
398
  if tags:
392
- copy_target['Tagging'] = tags
393
- response = self.s3.copy_object(CopySource=copy_source, **copy_target)
399
+ copy_args['Tagging'] = tags
400
+ if self.kms_key_id:
401
+ copy_args['ServerSideEncryption'] = 'aws:kms'
402
+ copy_args['SSEKMSKeyId'] = self.kms_key_id
403
+ response = self.s3.copy_object(
404
+ **copy_args, CopySource=copy_source
405
+ )
394
406
  PRINT(f'Response from boto3 copy:\n{response}')
395
407
  PRINT(f'Object {bucket}/{key} copied back to its original location in S3')
396
408
  return response