Skip to content

Commit

Permalink
var name clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed May 24, 2024
1 parent 94b84ec commit da6e574
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/credential-provider-imds/src/fromInstanceMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
* Instance Metadata Service
*/
export const fromInstanceMetadata = (init: RemoteProviderInit = {}): Provider<InstanceMetadataCredentials> =>
staticStabilityProvider(getInstanceImdsProvider(init), { logger: init.logger });
staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });

const getInstanceImdsProvider = (init: RemoteProviderInit) => {
/**
* @internal
*/
const getInstanceMetadataProvider = (init: RemoteProviderInit = {}) => {
// when set to true, metadata service will not fetch token
let disableFetchToken = false;
const { logger, profile } = init;
Expand Down Expand Up @@ -154,7 +157,7 @@ const getMetadataToken = async (options: RequestOptions) =>
const getProfile = async (options: RequestOptions) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();

const getCredentialsFromProfile = async (profile: string, options: RequestOptions, init: RemoteProviderInit) => {
const credsResponse = JSON.parse(
const credentialsResponse = JSON.parse(
(
await httpRequest({
...options,
Expand All @@ -163,11 +166,11 @@ const getCredentialsFromProfile = async (profile: string, options: RequestOption
).toString()
);

if (!isImdsCredentials(credsResponse)) {
if (!isImdsCredentials(credentialsResponse)) {
throw new CredentialsProviderError("Invalid response received from instance metadata service.", {
logger: init.logger,
});
}

return fromImdsCredentials(credsResponse);
return fromImdsCredentials(credentialsResponse);
};

0 comments on commit da6e574

Please sign in to comment.