def share_backup_with_account(self, backup_region: str, backup_id: str,
                               aws_account_id: str):
     ec2 = AwsHelper.boto3_session('ec2',
                                   region_name=backup_region,
                                   arn=self.role_arn,
                                   external_id=self.role_external_id)
     image = ec2.Image(backup_id)
     image.modify_attribute(
         Attribute='launchPermission',
         LaunchPermission={'Add': [{
             'UserId': aws_account_id
         }]},
         UserIds=[aws_account_id],
         OperationType='add')
     for bdm in image.block_device_mappings:
         if 'Ebs' in bdm:
             snap_id = bdm['Ebs']['SnapshotId']
             snapshot = ec2.Snapshot(snap_id)
             snapshot.modify_attribute(Attribute='createVolumePermission',
                                       CreateVolumePermission={
                                           'Add': [{
                                               'UserId': aws_account_id
                                           }]
                                       },
                                       UserIds=[aws_account_id],
                                       OperationType='add')
Beispiel #2
0
 def get_backup_resource(self, region: str,
                         backup_id: str) -> BackupResource:
     ec2 = AwsHelper.boto3_session('ec2',
                                   region_name=region,
                                   arn=self.role_arn,
                                   external_id=self.role_external_id)
     snapshot = ec2.Snapshot(backup_id)
     d_tags = dict(map(lambda t: (t['Key'], t['Value']), snapshot.tags))
     return BackupResource.construct(d_tags['shelvery:tag_name'], backup_id,
                                     d_tags)
Beispiel #3
0
 def share_backup_with_account(self, backup_region: str, backup_id: str,
                               aws_account_id: str):
     ec2 = AwsHelper.boto3_session('ec2',
                                   region_name=backup_region,
                                   arn=self.role_arn,
                                   external_id=self.role_external_id)
     snapshot = ec2.Snapshot(backup_id)
     snapshot.modify_attribute(
         Attribute='createVolumePermission',
         CreateVolumePermission={'Add': [{
             'UserId': aws_account_id
         }]},
         UserIds=[aws_account_id],
         OperationType='add')