Skip to content

first attempt to add cross account permissions to aws#24

Open
lynchc wants to merge 1 commit into
mainfrom
cl/crossaccount
Open

first attempt to add cross account permissions to aws#24
lynchc wants to merge 1 commit into
mainfrom
cl/crossaccount

Conversation

@lynchc

@lynchc lynchc commented May 8, 2026

Copy link
Copy Markdown

This separates calls bwtween vpcs / enis and ec2 / instances attachments

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

Fixes: #issue-number

<!-- Enter the release note text here if needed or remove this section! -->

This separates calls bwtween vpcs / enis and ec2 / instances attachments
@tanle-ux

tanle-ux commented May 11, 2026

Copy link
Copy Markdown

High-level design feedback

1. Consider generalizing to N accounts instead of 2

The hard-coded local/remote split is specific to Roblox's topology and may be too narrow to get accepted upstream. A map-based multi-account design would be more general and easier for the community to adopt and maintain.

One approach:

type MultiAccountEC2Client struct {
    logger         *slog.Logger
    clients        map[AccountRole]EC2API
    localAccountID string
}

type AccountRole string

const (
    RoleNetwork AccountRole = "network" // VPC, subnets, ENIs
    RoleCompute AccountRole = "compute" // EC2 instances, instance types
    RoleEIP     AccountRole = "eip"     // Elastic IPs
)

This makes the account-to-operation mapping explicit and extensible, rather than baking in a two-client assumption.

2. If keeping the two-account design, minor nit:

  • Rename crossaccount.gocross_account.go or cross_account_client.go (Go file naming convention uses underscores for multi-word names)

@tanle-ux tanle-ux left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

will continue tmr.

}

func (c *CrossAccountEC2Client) AssociateEIP(ctx context.Context, eniID string, eipTags ipamTypes.Tags) (string, error) {
return c.local.AssociateEIP(ctx, eniID, eipTags)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should it be c.remote?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

eip's can be either local or remote for the avg user. we don't allow them at all in rbx, but if we did, we would want them in the clients local account. Otherwise we'd have every customer eip in network and it would get messy

return c.remote.GetRouteTables(ctx, vpcID)
}

//TODO: not sure if I need this

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do we need this comment? it seems correct to me.

logfields.Error, permErr,
)
if delErr := c.remote.DeleteNetworkInterface(ctx, eniID); delErr != nil {
//TODO: maybe make a bigger deal of this

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A Warn log is insufficient here. A leaked ENI in the network account causes lasting cost and attachment-slot exhaustion. Emit a metric and consider logging at Error level so it surfaces in alerting.

Comment thread pkg/aws/eni/instances.go
@@ -36,6 +36,7 @@ type EC2API interface {

GetDetachedNetworkInterfaces(ctx context.Context, tags ipamTypes.Tags, maxResults int32) ([]string, error)
CreateNetworkInterface(ctx context.Context, toAllocate int32, subnetID, desc string, groups []string, allocatePrefixes bool) (string, *eniTypes.ENI, error)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CreateNetworkInterfacePermission is only called from within CrossAccountEC2Client.CreateNetworkInterface, yet adding it to EC2API forces every implementation to carry this cross-account detail. Consider keeping it out of the shared interface and calling it via a narrower sub-interface or directly on the concrete type inside crossaccount.go.

{ID: "vpc-local", PrimaryCIDR: "192.168.0.0/16"},
}
noRouteTables = []*ipamTypes.RouteTable{}
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove the // MADE BY AI. REVIEWED annotation before merge -- it carries no information for future readers.

Comment thread flake.nix
@@ -0,0 +1,48 @@
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we don't need flake.nix and flake.lock in this PR.

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