Skip to content

fix: registry commands respect AWS_CONFIG_FILE#927

Open
yuriipolishchuk wants to merge 2 commits intofwdcloudsec:mainfrom
yuriipolishchuk:fix/registry-respect-aws-config-file
Open

fix: registry commands respect AWS_CONFIG_FILE#927
yuriipolishchuk wants to merge 2 commits intofwdcloudsec:mainfrom
yuriipolishchuk:fix/registry-respect-aws-config-file

Conversation

@yuriipolishchuk
Copy link
Copy Markdown

@yuriipolishchuk yuriipolishchuk commented Mar 9, 2026

Fixes #926

Registry commands (add, sync, remove, setup) ignored AWS_CONFIG_FILE and always used ~/.aws/config. This was fixed for assume in #229 but missed for registry.

The fix reuses cfaws.GetAWSConfigPath() — the same function already used by assume, granted sso, and granted credentials to resolve the config path.

Added tests for both custom and default paths.

granted registry add/sync/remove/setup ignored the AWS_CONFIG_FILE
environment variable and always wrote to ~/.aws/config. The assume
command was fixed for this in fwdcloudsec#229, but registry commands were missed.

This change reuses cfaws.GetAWSConfigPath() which already handles
AWS_CONFIG_FILE correctly, consistent with AWS CLI behavior:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
Copy link
Copy Markdown
Collaborator

@meyerjrr meyerjrr left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Just have one minor nitpick

Comment thread pkg/granted/registry/ini.go Outdated

configPath := filepath.Join(h, ".aws", "config")
return configPath, nil
return cfaws.GetAWSConfigPath(), nil
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of returning cfaws.GetAWSConfigPath() here can we update the uses of getDefaultAWSConfigLocation in the registry to instead just call cfaws.GetAWSConfigPath() for consistency across the codebase?

Copy link
Copy Markdown
Author

@yuriipolishchuk yuriipolishchuk May 3, 2026

Choose a reason for hiding this comment

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

@meyerjrr Done in 6de7be7 — dropped the wrapper and inlined cfaws.GetAWSConfigPath() in loadAWSConfigFile. Also tightened the default-path test to sandbox HOME (so it doesn't touch the real ~/.aws/) and assert the exact resolved path.

…test

Drop the getDefaultAWSConfigLocation wrapper and call cfaws.GetAWSConfigPath
directly to match how assume / sso / credentials already resolve the AWS
config path (per review on fwdcloudsec#927).

Also sandbox HOME and tighten the path assertion in
TestLoadAWSConfigFile_DefaultPath so it neither touches the user's real
~/.aws/ nor passes for unrelated paths like ".aws/config-backup".
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.

Registry commands ignore AWS_CONFIG_FILE environment variable

2 participants