Skip to content
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

LoadBalancerV2 target groups: include port and protocol to EC2Instance #1278

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cartography/intel/aws/ec2/load_balancer_v2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ def load_load_balancer_v2_target_groups(
ingest_instances = """
MATCH (elbv2:LoadBalancerV2{id: $ID}), (instance:EC2Instance{instanceid: $INSTANCE_ID})
MERGE (elbv2)-[r:EXPOSE]->(instance)
ON CREATE SET r.firstseen = timestamp()
SET r.lastupdated = $update_tag
ON CREATE SET r.firstseen = timestamp(),
r.target_group_arn = $TARGET_GROUP_ARN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for the target_group_arn to change? To be safe, let's move this to the SET clause.

SET r.lastupdated = $update_tag,
r.port = $PORT, r.protocol = $PROTOCOL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed a comma. Needs to be

    SET r.lastupdated = $update_tag,
        r.port = $PORT, r.protocol = $PROTOCOL

Also, is the ARN of the target group available? If so, maybe we should include the ARN of the target group as r.target_group_arn so that it's easily searchable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh also let's remember to update the schema doc

WITH instance
MATCH (aa:AWSAccount{id: $AWS_ACCOUNT_ID})
MERGE (aa)-[r:RESOURCE]->(instance)
Expand All @@ -177,6 +179,9 @@ def load_load_balancer_v2_target_groups(
ID=load_balancer_id,
INSTANCE_ID=instance,
AWS_ACCOUNT_ID=current_aws_account_id,
TARGET_GROUP_ARN=target_group.get('TargetGroupArn'),
PORT=target_group.get('Port'),
PROTOCOL=target_group.get('Protocol'),
update_tag=update_tag,
)

Expand Down
1 change: 1 addition & 0 deletions docs/root/modules/aws/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ Represents an Elastic Load Balancer V2 ([Application Load Balancer](https://docs
```
(LoadBalancerV2)-[EXPOSE]->(EC2Instance)
```
`EXPOSE` relationshiohip also holds the protocol, port and TargetGroupArn the load balancer points to.

- LoadBalancerV2's can be part of EC2SecurityGroups but only if their `type` = "application". NLBs don't have SGs.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import find_packages
from setuptools import setup

__version__ = '0.87.0'
__version__ = '0.88.0rc1'


setup(
Expand Down
Loading