Skip to content

runners; Add accountId to findAmiID #6744

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

seemethere
Copy link
Member

This should resolve issues where accountId is needed for findAmiID

Resolves #6688

This should resolve issues where accountId is needed for findAmiID

Signed-off-by: Eli Uriegas <[email protected]>
Copy link

vercel bot commented Jun 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
torchci ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2025 5:17pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 11, 2025
export async function findAmiID(metrics: Metrics, region: string, filter: string, owners = 'amazon'): Promise<string> {
const ec2 = new EC2({ region: region });
const accountId = await getCurrentAccountId();
const allOwners = [accountId, owners];

Check failure

Code scanning / lintrunner

SPACES/trailing spaces Error

This line has trailing spaces; please remove them.
Signed-off-by: Eli Uriegas <[email protected]>
Signed-off-by: Eli Uriegas <[email protected]>
Signed-off-by: Eli Uriegas <[email protected]>
Copy link
Contributor

@ZainRizvi ZainRizvi left a comment

Choose a reason for hiding this comment

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

Vibe coding ft(almost)w

export async function findAmiID(metrics: Metrics, region: string, filter: string, owners = 'amazon'): Promise<string> {
const ec2 = new EC2({ region: region });
const accountId = await getCurrentAccountId();
const allOwners = [accountId, owners];
Copy link
Contributor

Choose a reason for hiding this comment

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

// Helper function to get the current AWS account ID
async function getCurrentAccountId(): Promise<string> {
const sts = new STS();
const identity = await sts.getCallerIdentity().promise();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please double check to see if the lambdas have access to this identity before checking in the code. But I suspect my comment below includes all the identities that would be needed

Copy link
Member Author

Choose a reason for hiding this comment

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

Claude seemed to think that we already did

export async function findAmiID(metrics: Metrics, region: string, filter: string, owners = 'amazon'): Promise<string> {
const ec2 = new EC2({ region: region });
const accountId = await getCurrentAccountId();
const allOwners = [accountId, owners];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, note that the function definition has "owners" passed in here as an optional parameter that no caller actually uses.

Consider changing that optional parameter's type to a list of strings and moving this owner identification code to a higher state of being 😇

const sts = new STS();
const identity = await sts.getCallerIdentity().promise();
if (!identity.Account) {
throw new Error('Unable to retrieve AWS account ID');
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of failing with error, should we just log the error and fallback to Amazon only images ?

@atalman
Copy link
Contributor

atalman commented Jun 11, 2025

What is our test plan on deploying this ? Is there a way to test it in canary only ?

Signed-off-by: Eli Uriegas <[email protected]>
}

export async function findAmiID(
metrics: Metrics,

Check failure

Code scanning / lintrunner

SPACES/trailing spaces Error

This line has trailing spaces; please remove them.

export async function findAmiID(
metrics: Metrics,
region: string,

Check failure

Code scanning / lintrunner

SPACES/trailing spaces Error

This line has trailing spaces; please remove them.
export async function findAmiID(
metrics: Metrics,
region: string,
filter: string,

Check failure

Code scanning / lintrunner

SPACES/trailing spaces Error

This line has trailing spaces; please remove them.
const ec2 = new EC2({ region: region });
const accountId = await getCurrentAccountId();
const lfAccountId = '391835788720';

Check failure

Code scanning / lintrunner

SPACES/trailing spaces Error

This line has trailing spaces; please remove them.
const accountId = await getCurrentAccountId();
const lfAccountId = '391835788720';

const allOwners = accountId

Check failure

Code scanning / lintrunner

SPACES/trailing spaces Error

This line has trailing spaces; please remove them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Autoscaler] The autoscaler experiments are unable to find custom AMIs when they're set as an experiment
4 participants