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

chore(ec2): improve handling of ENIs #3798

Merged
merged 2 commits into from
Apr 17, 2024
Merged

chore(ec2): improve handling of ENIs #3798

merged 2 commits into from
Apr 17, 2024

Conversation

MrCloudSec
Copy link
Member

Description

Improve handling of ENIs by doing a global function.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@MrCloudSec MrCloudSec requested review from a team April 16, 2024 12:17
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Apr 16, 2024
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.54%. Comparing base (6396d90) to head (0c1997b).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3798      +/-   ##
==========================================
+ Coverage   85.48%   85.54%   +0.06%     
==========================================
  Files         731      731              
  Lines       22644    22661      +17     
==========================================
+ Hits        19357    19386      +29     
+ Misses       3287     3275      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 272 to 275
for sg in interface.get("Groups", []):
for security_group in self.security_groups:
if security_group.id == sg["GroupId"]:
security_group.network_interfaces.append(eni)
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this to a different function? One to get all the network interfaces ✅ other to link them with their security groups.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@@ -472,16 +469,6 @@ class NetworkACL(BaseModel):
tags: Optional[list] = []


class NetworkInterface(BaseModel):
public_ip: str
Copy link
Member

Choose a reason for hiding this comment

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

Why this is removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it is inside associations

@MrCloudSec MrCloudSec requested a review from jfagoagas April 16, 2024 14:29
for security_group in self.security_groups:
if security_group.id == sg["GroupId"]:
security_group.network_interfaces.append(eni)
self.__add_network_interfaces_to_security_groups__(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe my point was not clear, I thought that this should be called in the init function after calling __describe_network_interfaces__ to let that function to do their thing as we do in all the service's functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did it like that so we don't have to iterate again through the ENIs.

@MrCloudSec MrCloudSec requested a review from jfagoagas April 17, 2024 09:23
Copy link
Member

@jfagoagas jfagoagas left a comment

Choose a reason for hiding this comment

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

👍

@jfagoagas jfagoagas merged commit d79ec44 into master Apr 17, 2024
11 checks passed
@jfagoagas jfagoagas deleted the improve-ec2-enis branch April 17, 2024 11:12
MrCloudSec added a commit that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants