Skip to content

Commit

Permalink
Refactor EC2 Volume to allow optional properties. (#1231)
Browse files Browse the repository at this point in the history
The existing EC2 Volume transformation assumes all properties will be
present. See [EC2 API Reference for
Volumes](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Volume.html)
to see that all properties on the Volume are optional.
  • Loading branch information
andrew-womeldorf authored Aug 14, 2023
1 parent 875df3a commit d4c450e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cartography/intel/aws/ec2/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ def transform_volumes(volumes: List[Dict[str, Any]], region: str, current_aws_ac
volume_id = volume['VolumeId']
raw_vol = ({
'Arn': build_arn('ec2', current_aws_account_id, 'volume', volume_id, region),
'AvailabilityZone': volume['AvailabilityZone'],
'CreateTime': volume['CreateTime'],
'Encrypted': volume['Encrypted'],
'Size': volume['Size'],
'State': volume['State'],
'OutpostArn': volume['OutpostArn'],
'SnapshotId': volume['SnapshotId'],
'Iops': volume['Iops'],
'FastRestored': volume['FastRestored'],
'MultiAttachEnabled': volume['MultiAttachEnabled'],
'VolumeType': volume['VolumeType'],
'AvailabilityZone': volume.get('AvailabilityZone'),
'CreateTime': volume.get('CreateTime'),
'Encrypted': volume.get('Encrypted'),
'Size': volume.get('Size'),
'State': volume.get('State'),
'OutpostArn': volume.get('OutpostArn'),
'SnapshotId': volume.get('SnapshotId'),
'Iops': volume.get('Iops'),
'FastRestored': volume.get('FastRestored'),
'MultiAttachEnabled': volume.get('MultiAttachEnabled'),
'VolumeType': volume.get('VolumeType'),
'VolumeId': volume_id,
'KmsKeyId': volume['KmsKeyId'],
'KmsKeyId': volume.get('KmsKeyId'),
})

if not active_attachments:
Expand Down

0 comments on commit d4c450e

Please sign in to comment.