-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1210: EBSVolume => new data model, Allow node attr updates from multiple intel modules #1214
Changes from all commits
c0d9ac4
facb63b
698a813
477c4b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Optional | ||
|
||
|
||
def build_arn( | ||
resource: str, | ||
account: str, | ||
typename: str, | ||
name: str, | ||
region: Optional[str] = None, | ||
partition: Optional[str] = None, | ||
) -> str: | ||
if not partition: | ||
# TODO: support partitions from others. Please file an issue on this if needed, would love to hear from you | ||
partition = 'aws' | ||
if not region: | ||
# Some resources are present in all regions, e.g. IAM policies | ||
region = "" | ||
return f"arn:{partition}:{resource}:{region}:{account}:{typename}/{name}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,23 @@ | |
|
||
@dataclass(frozen=True) | ||
class EBSVolumeNodeProperties(CartographyNodeProperties): | ||
arn: PropertyRef = PropertyRef('Arn', extra_index=True) | ||
id: PropertyRef = PropertyRef('VolumeId') | ||
volumeid: PropertyRef = PropertyRef('VolumeId', extra_index=True) | ||
region: PropertyRef = PropertyRef('Region', set_in_kwargs=True) | ||
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True) | ||
deleteontermination: PropertyRef = PropertyRef('DeleteOnTermination') | ||
availabilityzone: PropertyRef = PropertyRef('AvailabilityZone') | ||
createtime: PropertyRef = PropertyRef('CreateTime') | ||
encrypted: PropertyRef = PropertyRef('Encrypted') | ||
size: PropertyRef = PropertyRef('Size') | ||
state: PropertyRef = PropertyRef('State') | ||
outpostarn: PropertyRef = PropertyRef('OutpostArn') | ||
snapshotid: PropertyRef = PropertyRef('SnapshotId') | ||
iops: PropertyRef = PropertyRef('Iops') | ||
fastrestored: PropertyRef = PropertyRef('FastRestored') | ||
multiattachenabled: PropertyRef = PropertyRef('MultiAttachEnabled') | ||
type: PropertyRef = PropertyRef('VolumeType') | ||
kmskeyid: PropertyRef = PropertyRef('KmsKeyId') | ||
|
||
|
||
@dataclass(frozen=True) | ||
|
@@ -53,6 +66,9 @@ class EBSVolumeToEC2Instance(CartographyRelSchema): | |
|
||
@dataclass(frozen=True) | ||
class EBSVolumeSchema(CartographyNodeSchema): | ||
""" | ||
EBS Volume properties as returned from the EBS Volume API response | ||
""" | ||
label: str = 'EBSVolume' | ||
properties: EBSVolumeNodeProperties = EBSVolumeNodeProperties() | ||
sub_resource_relationship: EBSVolumeToAWSAccount = EBSVolumeToAWSAccount() | ||
|
@@ -61,3 +77,31 @@ class EBSVolumeSchema(CartographyNodeSchema): | |
EBSVolumeToEC2Instance(), | ||
], | ||
) | ||
|
||
|
||
@dataclass(frozen=True) | ||
class EBSVolumeInstanceProperties(CartographyNodeProperties): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the sample There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, will update |
||
""" | ||
EBS Volume properties as known by an EC2 instance. | ||
The EC2 instance API response includes a `deleteontermination` field and the volume id. | ||
""" | ||
arn: PropertyRef = PropertyRef('Arn', extra_index=True) | ||
id: PropertyRef = PropertyRef('VolumeId') | ||
volumeid: PropertyRef = PropertyRef('VolumeId', extra_index=True) | ||
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True) | ||
deleteontermination: PropertyRef = PropertyRef('DeleteOnTermination') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @serge-wq [comment 1 of 2] - ah here we go. Here an EBS volume as known by an EC2 instance has a |
||
|
||
|
||
@dataclass(frozen=True) | ||
class EBSVolumeInstanceSchema(CartographyNodeSchema): | ||
""" | ||
EBS Volume from EC2 Instance API response. This is separate from `EBSVolumeSchema` to prevent issue #1210. | ||
""" | ||
label: str = 'EBSVolume' | ||
properties: EBSVolumeInstanceProperties = EBSVolumeInstanceProperties() | ||
sub_resource_relationship: EBSVolumeToAWSAccount = EBSVolumeToAWSAccount() | ||
other_relationships: OtherRelationships = OtherRelationships( | ||
[ | ||
EBSVolumeToEC2Instance(), | ||
], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serge-wq [comment 2 of 2] - .. but the EBSVolume by itself doesn't have that field. It also has fields that are not known by the EBSVolumeInstance.
The description of this PR shows more details on this decision.