-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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) |
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.
Could you move this to a different function? One to get all the network interfaces ✅ other to link them with their security groups.
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.
Done!
@@ -472,16 +469,6 @@ class NetworkACL(BaseModel): | |||
tags: Optional[list] = [] | |||
|
|||
|
|||
class NetworkInterface(BaseModel): | |||
public_ip: str |
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.
Why this is removed?
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.
Because it is inside associations
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__( |
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.
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.
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.
I did it like that so we don't have to iterate again through the ENIs.
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.
👍
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.