Skip to content

Fix metadata server path resolution issues#294

Merged
DevOpsDave merged 9 commits intomasterfrom
metadata-fix
Jan 29, 2026
Merged

Fix metadata server path resolution issues#294
DevOpsDave merged 9 commits intomasterfrom
metadata-fix

Conversation

@samsolaimani
Copy link

@samsolaimani samsolaimani commented Jan 26, 2026

Summary

Fixes three path resolution errors that prevented the metadata server from starting properly.

Changes

  1. Metadata server path: Changed from '../lib/metadata-server.js' to '../metadata-server.js'
  2. Forever daemon root: Fixed from '../' to '../../../../' to properly resolve to project root
  3. Service files path: Updated from '../service' to '../../../../service'

These paths must resolve correctly from the dist/src/lib/handlers/ directory context after TypeScript compilation.

Additional changes by Dave:

  • Added .npmrc to .gitignore and removed it from the repo.
  • Fixed the flaky metadata server. It needed exception handling.
  • Fixed the mac os operational setup for starting the server.
  • Fixed src/lib/getMetadata.ts return type to Promise<Metadata | undefined>
  • Created tear down and re-test from scratch testing scripts in a new scripts directory at project root. The testing scripts are focused around the metadata server.
  • I commented out the e2e tests since they were failing on pulling with jfrog from artifactory. I don't have time to deal with that so I will make a separate story to address that.
  • Updated the README.md calling out that users should be pulling alks-cli from artifactory and notes how to setup their ~/.npmrc on how to do so.
  • I also removed the contents of the dist/ directory from the repo and added the directory to .gitignore. Those contents should be dynamically generated every time. Build consistency is ensured by npm-shrinkwrap.json.

Testing Instructions

  1. Build the project: npm run build
  2. Start the metadata server: node dist/src/bin/alks.js server start
  3. Verify server is running: curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
    • Should return: alks
  4. Test full credentials endpoint: curl http://169.254.169.254/latest/meta-data/iam/security-credentials/alks
    • Should return JSON with AWS credentials

Note: Testing must use 169.254.169.254 (not 127.0.0.1:45000) as the pf rules redirect traffic.

Related

Fixes three path resolution errors that prevented the metadata server from starting:
1. Corrected metadata-server.js path from '../lib/metadata-server.js' to '../metadata-server.js'
2. Fixed forever daemon root from '../' to '../../../../' to properly resolve to project root
3. Updated service file path from '../service' to '../../../../service'

These changes ensure paths correctly resolve from the dist/src/lib/handlers/ directory context after TypeScript compilation.

Resolves DE565327

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@samsolaimani samsolaimani self-assigned this Jan 26, 2026
@samsolaimani samsolaimani added bug release/patch Indicates an update without breaking changes or new features labels Jan 26, 2026
@DevOpsDave
Copy link
Contributor

@samsolaimani I reviewed this and it looks good. At first I drilled into the deep relative paths thinking they made things brittle but after looking more into it I left it as is. Dealing with the deep literal paths would need more automation that I would rather not put into this PR. I really like the description for this PR. It was short and concise. Also the testing instructions were appreciated.

I made some additional changes:

  • Added .npmrc to .gitignore and removed it from the repo.
  • Fixed the flaky metadata server. It needed exception handling.
  • Fixed the mac os operational setup for starting the server.
  • Fixed src/lib/getMetadata.ts return type to Promise<Metadata | undefined>
  • Created tear down and re-test from scratch testing scripts in a new scripts directory at project root. The testing scripts are focused around the metadata server.
  • I commented out the e2e tests since they were failing on pulling with jfrog from artifactory. I don't have time to deal with that so I will make a separate story to address that.
  • Updated the README.md calling out that users should be pulling alks-cli from artifactory and notes how to setup their ~/.npmrc on how to do so.
  • I also removed the contents of the dist/ directory from the repo and added the directory to .gitignore. Those contents should be dynamically generated every time. Build consistency is ensured by npm-shrinkwrap.json.

We should have someone else now give a final review.

Copy link
Contributor

@codykoelemay codykoelemay left a comment

Choose a reason for hiding this comment

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

Followed the testing instructions and looks like it worked. Returned credentials

I had to do a additional command alks server configure -a awscoxautolabs95 -r LabAdmin before the last step and then it returned credentials

@DevOpsDave DevOpsDave merged commit fbfef9f into master Jan 29, 2026
5 checks passed
@DevOpsDave DevOpsDave deleted the metadata-fix branch January 29, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug release/patch Indicates an update without breaking changes or new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants