Skip to content

Commit e733230

Browse files
committed
fix config selector fallback behaviour
1 parent 1b4f991 commit e733230

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/credential-provider-imds/src/fromInstanceMetadata.e2e.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("fromInstanceMetadata (Live EC2 E2E Tests)", () => {
88
let imdsAvailable = false;
99

1010
beforeEach(async () => {
11-
process.env = { ...originalEnv };
11+
process.env = { ...originalEnv, AWS_EC2_INSTANCE_PROFILE_NAME: "foo-profile" };
1212

1313
// Check IMDS availability
1414
try {
@@ -87,7 +87,6 @@ describe("fromInstanceMetadata (Live EC2 E2E Tests)", () => {
8787
it("Uses configured profile name from env", async () => {
8888
if (!imdsAvailable) return;
8989

90-
process.env.AWS_EC2_INSTANCE_PROFILE_NAME = "foo-profile";
9190
const provider = fromInstanceMetadata({ timeout: 1000 });
9291

9392
try {

packages/credential-provider-imds/src/fromInstanceMetadata.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,17 @@ export const throwIfImdsTurnedOff = async (profile?: string, logger?: any): Prom
211211
// Check environment variable
212212
environmentVariableSelector: (env) => {
213213
const envValue = env[ENV_IMDS_DISABLED];
214+
if (envValue === undefined) {
215+
return undefined;
216+
}
214217
return envValue === "true";
215218
},
216219
// Check config file
217220
configFileSelector: (profile) => {
218221
const profileValue = profile[CONFIG_IMDS_DISABLED];
222+
if (profileValue === undefined) {
223+
return undefined;
224+
}
219225
return profileValue === "true";
220226
},
221227
default: false,

0 commit comments

Comments
 (0)