Skip to content
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

@nx/s3-cache does not work with dynamic AWS profiles #30594

Open
2 of 4 tasks
comp615 opened this issue Apr 2, 2025 · 1 comment
Open
2 of 4 tasks

@nx/s3-cache does not work with dynamic AWS profiles #30594

comp615 opened this issue Apr 2, 2025 · 1 comment

Comments

@comp615
Copy link

comp615 commented Apr 2, 2025

Current Behavior

Right now, the plugin appears to instantiate the aws profile from the nxJson.ssoProfile:

function createIdentityProvider(nxJson) {
  var _a;
  return (0, import_credential_providers.createCredentialChain)(
    fromNxJson(nxJson),
    (0, import_credential_providers.fromNodeProviderChain)({
      profile: (_a = nxJson.s3) == null ? void 0 : _a.ssoProfile
    })
  );
}

This means that the direct argument takes precedence over the AWS_PROFILE env var. However, at the same time, it's not possible to define this locally, and override it for CI...that is to say use a different profile in each environment.

Expected Behavior

There should be a mechanism to allow us to specify a different profile in each env, or at least to not interfere with the native AWS env vars. For instance, removing the profile field from my nx.json allows caching to work in CI because it uses our AWS_PROFILE (but this isn't defined locally by default).

GitHub Repo

No response

Steps to Reproduce

  1. Install s3-client
  2. Configure nxJson with any ssoProfile value
  3. Notice that AWS_PROFILE is not used in the credentials

Nx Report

Node           : 20.17.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.11.0

nx                     : 20.7.1
@nx/js                 : 20.7.1
@nx/jest               : 20.7.1
@nx/eslint             : 20.7.1
@nx/workspace          : 20.7.1
@nx/cypress            : 20.7.1
@nx/devkit             : 20.7.1
@nx/eslint-plugin      : 20.7.1
@nx/module-federation  : 20.7.1
@nx/plugin             : 20.7.1
@nx/react              : 20.7.1
@nx/storybook          : 20.7.1
@nx/vite               : 20.7.1
@nx/web                : 20.7.1
typescript             : 5.5.4

---------------------------------------
Nx key licensed packages
Licensed to ABC Inc..

@nx/s3-cache  : 1.3.0

---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/storybook/plugin
---------------------------------------
Community plugins:
@nx/s3-cache           : 1.3.0
---------------------------------------
Local workspace plugins:
---------------------------------------
Cache Usage: 229.94 MB / 92.64 GB

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Notice that the community plugins dodge this problem by preferring env vars:
https://github.com/robinpellegrims/pellegrims/blob/e5269065f0676a4e47731219ba85dbd5a2d18cf9/libs/nx-remotecache-s3/src/lib/s3-client.ts#L81

It'd be reasonable to just look for AWS_PROFILE and use that first if it exists...or to create a new NX_AWS_PROFILE.

@comp615 comp615 changed the title @nx/s3-cache does not work with dynamic profiles @nx/s3-cache does not work with dynamic AWS profiles Apr 2, 2025
@Michsior14
Copy link
Contributor

I would also love to see nx specific AWS variables for key/secret, similar as in the mentioned package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants