Skip to content

feat: AWS EC2 route table initial support#1530

Merged
achantavy merged 23 commits intomasterfrom
routetables
Apr 18, 2025
Merged

feat: AWS EC2 route table initial support#1530
achantavy merged 23 commits intomasterfrom
routetables

Conversation

@achantavy
Copy link
Contributor

@achantavy achantavy commented Apr 13, 2025

Summary

Describe your changes.

Adds initial support for AWS EC2 route tables, routes, route associations, and subnet / gateway targets.

Schema diagram of what this PR accomplishes:

  • The dotted lines indicate not done yet
    route table model (3)

These can be resolved in a fast follow. For now, I think this is a decent chunk ready for review.

Related issues or links

Include links to relevant issues or other pages.

N/A

Checklist

Provide proof that this works (this makes reviews move faster). Please perform one or more of the following:

  • Update/add unit or integration tests.
  • Include a screenshot showing what the graph looked like before and after your changes.
    Screenshot 2025-04-17 at 9 26 07 PM
  • Include console log trace showing what happened before and after your changes.
    I have run this locally e2e and it works.

If you are changing a node or relationship:

If you are implementing a new intel module:

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 9 issues across 8 files. View them in mrge.io

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 7 issues across 8 files. View them in mrge.io

achantavy added a commit that referenced this pull request Apr 17, 2025
### Summary
> Describe your changes.

Adds integ tests for AWS VPC and IGW to unblock #1530.

Paying back some debt.

### Checklist

Provide proof that this works (this makes reviews move faster). Please
perform one or more of the following:
- [x] Update/add unit or integration tests.

---------

Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
Signed-off-by: Alex Chantavy <alex@subimage.io>
@achantavy achantavy requested a review from jychp April 18, 2025 04:52
Copy link
Collaborator

@jychp jychp left a comment

Choose a reason for hiding this comment

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

General feedback:
Overall, the code looks correct and functional.

Design question:
Do we really want to have a RouteTableAssociationSchema node? It seems to be a 1-to-1 relation between the parent and child nodes. Is this node truly necessary, or could it be replaced by a direct relationship between RouteTable and EC2Subnet (or other relevant nodes)?

route table for the VPC
"""
transformed = []
is_main = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Opinionated and non-blocking comment:
Having is_main default to false and targetdefault to"main"can be a bit confusing. I would have leftis_maindefaulting to false and settarget = "main"` inside the else block (since there's an else block, target will always be defined, so it's not an issue).

parts.append(route[key])
target = route[key]
break

Copy link
Collaborator

Choose a reason for hiding this comment

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

May be we can add a debug log here if the route target key is not found, that would help in the future if new target are added.

target = route[key]
break

return '|'.join(parts), target
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is an actual issue, but since the function's goal is to generate a unique ID, could there be a scenario where two routes within the same route_table_id both point to a KEY that's not defined in the array? In that case, the function would return something like route_table_id,None for both, which wouldn't be unique.

Copy link
Collaborator

Choose a reason for hiding this comment

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

after further reading it seems there is no impact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, this collision would happen if a new route target key is introduced by AWS that we don't support. I'll update so that we log a warning.

Otherwise though, the route data structure is like a 'union' data structure where it is designed so that only one of those target keys will be present.

@achantavy
Copy link
Contributor Author

Do we really want to have a RouteTableAssociationSchema node? It seems to be a 1-to-1 relation between the parent and child nodes. Is this node truly necessary, or could it be replaced by a direct relationship between RouteTable and EC2Subnet (or other relevant nodes)?

Good catch. Yeah, I struggled here a bit. I'm pretty new to AWS networking so I started out just by doing a naive object by object model. I think you're right: association to subnet / gateway is 1-1, and I think the design would be better to remove the intermediary

@achantavy
Copy link
Contributor Author

Oh, there is a reason why I did it:

  • If a route table is connected to an internet gateway via an association, then that means the internet gateway is used for ingress.

  • On the other hand, if a route table is connected to an internet gateway via a route, then that means the internet gateway is used for egress.

These cases seem complex and not straightforward so I figured the simplest way to avoid future misunderstanding was to just model it API object by API object. I'm open to thoughts here though on a smarter way.

@jychp
Copy link
Collaborator

jychp commented Apr 18, 2025

I think both approaches are valid, but there should be clear guidance at the project level.

After a bit of thought, here’s my take:

  • Stick as closely as possible to the source provider’s data model for the base nodes.
  • Introduce an abstraction layer only when we need to represent more generic concepts shared across multiple providers.

This way, we preserve the maximum amount of information, keep the tool easy to adopt for anyone (e.g., if I come from AWS, I don’t need to learn a new data model—it’s the same as AWS), and still allow for cross-provider intelligence through higher-level abstractions, if needed.

@achantavy
Copy link
Contributor Author

Stick as closely as possible to the source provider’s data model for the base nodes.
Introduce an abstraction layer only when we need to represent more generic concepts shared across multiple providers.

Agree

@achantavy
Copy link
Contributor Author

Will take an action to add that to intel module documentation

@jychp jychp self-requested a review April 18, 2025 18:03
Signed-off-by: Alex Chantavy <alex@subimage.io>
Copy link
Collaborator

@jychp jychp left a comment

Choose a reason for hiding this comment

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

LGTM

@achantavy achantavy merged commit df06b59 into master Apr 18, 2025
8 checks passed
@achantavy achantavy deleted the routetables branch April 18, 2025 21:01
@achantavy
Copy link
Contributor Author

@krisek - we finally got around to it; thought you'd find this interesting :)

should be in 0.102.0rc2

@jychp jychp mentioned this pull request May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants