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

Load sso-session and services sections of config files in loadSharedConfigFiles #991

Closed
trivikr opened this issue Oct 6, 2023 · 1 comment · Fixed by #993
Closed

Load sso-session and services sections of config files in loadSharedConfigFiles #991

trivikr opened this issue Oct 6, 2023 · 1 comment · Fixed by #993

Comments

@trivikr
Copy link
Contributor

trivikr commented Oct 6, 2023

Describe the bug

The utility loadSharedConfigFiles does not load sso-session and services sections of config files.

The services section is needed for reading service specific endpoints in aws/aws-sdk-js-v3#5324
The sso-session section can be read from loadSharedConfigFiles instead of having a separate utility loadSsoSessionData

Steps to reproduce

Code:

// test.mjs
import { tmpdir } from "os";
import { mkdtemp, rm, writeFile } from "fs/promises";
import { loadSharedConfigFiles } from "@smithy/shared-ini-file-loader"; // v2.0.13

const CONFIG = `/** Copy from example below */`;

const tempDir = await mkdtemp(tmpdir());

const filepath = `${tempDir}/credentials`;
await writeFile(filepath, ``);

const configFilepath = `${tempDir}/config`;
await writeFile(configFilepath, CONFIG);

const sharedConfigFiles = await loadSharedConfigFiles({
  filepath,
  configFilepath,
});

console.log(JSON.stringify(sharedConfigFiles, null, 2));

await rm(tempDir, { recursive: true });

SSO config:

const CONFIG = `[profile profile-with-sso-session]
sso_session = my-sso
sso_account_id = 111122223333
sso_role_name = SampleRole

[sso-session my-sso]
sso_region = us-east-1
sso_start_url = https://my-sso-portal.awsapps.com/start`;

Services config:

const CONFIG = `[profile profile-with-services]
services = my-services
endpoint_url = http://localhost:5567

[services my-services]
s3 = 
  endpoint_url = https://localhost:1234`;

Observed behavior

For sso-session:

{
  "configFile": {
    "profile-with-sso-session": {
      "sso_session": "my-sso",
      "sso_account_id": "111122223333",
      "sso_role_name": "SampleRole"
    }
  },
  "credentialsFile": {}
}

For services:

{
  "configFile": {
    "profile-with-services": {
      "services": "my-services",
      "endpoint_url": "http://localhost:5567"
    }
  },
  "credentialsFile": {}
}

Expected behavior

For sso-session:

{
  "configFile": {
    "profile-with-sso-session": {
      "sso_session": "my-sso",
      "sso_account_id": "111122223333",
      "sso_role_name": "SampleRole"
    },
    "sso-session.my-sso": {
      "sso_region": "us-east-1",
      "sso_start_url": "https://my-sso-portal.awsapps.com/start"
    }
  },
  "credentialsFile": {}
}

For services:

{
  "configFile": {
    "profile-with-services": {
      "services": "my-services",
      "endpoint_url": "http://localhost:5567"
    },
    "services.my-services": {
      "s3.endpoint_url": "https://localhost:1234"
    }
  },
  "credentialsFile": {}
}
@trivikr
Copy link
Contributor Author

trivikr commented Oct 6, 2023

Decision: we'll store . in a constant called CONFIG_PREFIX_SEPARATOR

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 a pull request may close this issue.

1 participant