Skip to content

Instantly share code, notes, and snippets.

@neilkuan
Created August 23, 2021 15:53
Show Gist options
  • Save neilkuan/097781fea8b12ed2c1185042f8f85dae to your computer and use it in GitHub Desktop.
Save neilkuan/097781fea8b12ed2c1185042f8f85dae to your computer and use it in GitHub Desktop.
aws-sdk-nodejs-InstanceMetadata.md
import { STS, GetCallerIdentityCommandOutput } from '@aws-sdk/client-sts';
import { fromInstanceMetadata } from '@aws-sdk/credential-provider-imds';

let data: GetCallerIdentityCommandOutput;
( async ()=> {
let sts: STS;

    sts = new STS({
    credentials: fromInstanceMetadata({
    timeout: 1000,
    maxRetries: 2,
    }),
});
data = await sts.getCallerIdentity({});
console.log(data.Arn)
console.log(456)

})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment