fix(aws): use default credential chain#403
Conversation
Signed-off-by: Oleg Leizerov <oleizerov@nvidia.com>
Signed-off-by: Oleg Leizerov <oleizerov@nvidia.com>
Greptile SummaryThis PR fixes the AWS provider credential resolution by removing the hardcoded EC2 instance-role fallback and delegating to the AWS SDK v2 default credential chain instead. This enables EKS Pod Identity, IRSA, and other SDK-supported mechanisms to work correctly when no explicit credentials are supplied.
Confidence Score: 5/5Safe to merge — the change replaces a narrow hardcoded fallback with the AWS SDK's well-tested default chain, and the new tests exercise the full refresh lifecycle. The refactor is straightforward and well-tested. Explicit credentials continue to take priority via StaticCredentialsProvider; everything else defers to the SDK. The container-credentials test with an expired-then-refreshed token validates the most complex scenario end-to-end. No logic regressions or behavioural edge cases were identified. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Loader called with cfg.Creds] --> B{len creds == 0?}
B -- Yes --> C[getCredentialsProvider returns nil\nLog: Using AWS SDK default credential chain]
B -- No --> D[decodeCredentials]
D -- Error --> E[Return HTTP 400]
D -- OK --> F[NewStaticCredentialsProvider\nLog: Using explicit Topograph AWS credentials]
C --> G[loadAWSConfig\nno WithCredentialsProvider opt]
F --> H[loadAWSConfig\nwith WithCredentialsProvider opt]
G --> I[config.LoadDefaultConfig\nAWS SDK default chain]
H --> I
I --> J[ec2.NewFromConfig]
subgraph AWS SDK Default Credential Chain
K[1. Environment variables\nAWS_ACCESS_KEY_ID etc.]
L[2. Shared config / credentials file]
M[3. Web Identity / IRSA]
N[4. Container / EKS Pod Identity]
O[5. EC2 IMDS instance role]
K --> L --> M --> N --> O
end
I -.->|when credsProvider is nil| K
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Loader called with cfg.Creds] --> B{len creds == 0?}
B -- Yes --> C[getCredentialsProvider returns nil\nLog: Using AWS SDK default credential chain]
B -- No --> D[decodeCredentials]
D -- Error --> E[Return HTTP 400]
D -- OK --> F[NewStaticCredentialsProvider\nLog: Using explicit Topograph AWS credentials]
C --> G[loadAWSConfig\nno WithCredentialsProvider opt]
F --> H[loadAWSConfig\nwith WithCredentialsProvider opt]
G --> I[config.LoadDefaultConfig\nAWS SDK default chain]
H --> I
I --> J[ec2.NewFromConfig]
subgraph AWS SDK Default Credential Chain
K[1. Environment variables\nAWS_ACCESS_KEY_ID etc.]
L[2. Shared config / credentials file]
M[3. Web Identity / IRSA]
N[4. Container / EKS Pod Identity]
O[5. EC2 IMDS instance role]
K --> L --> M --> N --> O
end
I -.->|when credsProvider is nil| K
Reviews (1): Last reviewed commit: "docs(aws): clarify credential selection" | Re-trigger Greptile |
|
/ok-to-test 4473a9e |
|
🌿 Preview your docs: https://nvidia-preview-pull-request-403.docs.buildwithfern.com/topograph |
Description
The AWS provider currently calls the EC2 instance-role credential provider whenever Topograph-specific credentials are absent. That bypasses the AWS SDK default credential chain, so EKS Pod Identity and IRSA credentials injected into the Topograph pod are ignored and the EC2 node role is used instead.
This change:
ec2:DescribeInstanceTopologypermission.Tests cover invalid and valid explicit credentials, explicit-over-environment precedence, environment credentials, EKS container credentials with an authorization token file, and refresh after expiration.
Validation
make qualifyAWS integration test
Validated commit
4473a9eon thenkx-slinky-gb300-dev-01EKS cluster:topographServiceAccount and its EKS Pod Identity association with the dedicatedaehiqzudem-topographIAM role.AWS_EC2_METADATA_DISABLED=trueto prevent fallback to the EC2 node role.The request used the AWS SDK default credential chain, extracted topology for 35 instances, updated the test ConfigMap, and completed with HTTP 200. No authorization errors occurred.
Checklist
git commit -s).