How to use the STS function from aws-sdk
Find comprehensive JavaScript aws-sdk.STS code examples handpicked from public code repositorys.
The aws-sdk.STS provides a way to request temporary AWS security credentials to access resources in AWS services.
GitHub: aws/amazon-chime-sdk-js
35 36 37 38 39 40 41 42 43 44 45 46
const chimeSDKMeetings = new AWS.ChimeSDKMeetings({ region: currentRegion }); if (endpoint !== 'https://service.chime.aws.amazon.com') { chimeSDKMeetings.endpoint = endpoint; } const sts = new AWS.STS({ region: 'us-east-1' }) const captureS3Destination = process.env.CAPTURE_S3_DESTINATION; if (captureS3Destination) { console.info(`S3 destination for capture is ${captureS3Destination}`)
+ 3 other calls in file
GitHub: noobaa/noobaa-core
37 38 39 40 41 42 43 44 45 46 47
s3ForcePathStyle: additionalParams.s3ForcePathStyle }); } async function generate_aws_sts_creds(params, roleSessionName) { const sts = new AWS.STS(); const creds = await (sts.assumeRoleWithWebIdentity({ RoleArn: params.aws_sts_arn, RoleSessionName: roleSessionName || defaultRoleSessionName, WebIdentityToken: (await fs.promises.readFile(projectedServiceAccountToken)).toString(),
+ 37 other calls in file
How does aws-sdk.STS work?
aws-sdk.STS is a constructor function in the AWS SDK for Node.js that provides methods to request temporary security credentials and manage AWS STS (Security Token Service) resources programmatically. It uses the AWS SDK to make requests to the STS service on behalf of the user and provides methods to manipulate IAM roles and federated user access to AWS services.
GitHub: rapid7/awsaml
18 19 20 21 22 23 24 25 26 27
const region = session.roleArn.includes('aws-us-gov') ? 'us-gov-west-1' : 'us-east-1'; Aws.config.update({region}); const sts = new Aws.STS(); const refreshResponseObj = Object.assign({}, ResponseObj, { accountId: session.accountId, roleName: session.roleName,
GitHub: BCDevOps/aws-login
65 66 67 68 69 70 71 72 73 74
} let accounts = parseSAMLResponse(decodedsamlResponse); let saml_read_role = process.env.samlReadRole.split(","); let roleArn = saml_read_role[1]; let sts = new AWS.STS(); let params = { DurationSeconds: 900, RoleArn: roleArn,
+ 59 other calls in file
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
const AWS = require("aws-sdk"); // Create an STS client const sts = new AWS.STS({ region: "us-west-2" }); // Call the assumeRole method to get temporary credentials sts.assumeRole( { RoleArn: "arn:aws:iam::123456789012:role/example-role", RoleSessionName: "example-session", DurationSeconds: 3600, }, (err, data) => { if (err) { console.log("Error", err); } else { console.log("Temporary credentials:", data.Credentials); } } );
This example creates a new STS client and calls the assumeRole method to get temporary credentials for the IAM role specified by the RoleArn parameter. The temporary credentials are valid for 1 hour (DurationSeconds: 3600) and the resulting credentials are printed to the console.
GitHub: briancoxGit/Jazz
40 41 42 43 44 45 46 47 48 49
if(serviceData){ if (isPrimary) { accessparams = {}; resolve(accessparams) } else { const sts = new AWS.STS({ region: process.env.REGION }); const roleSessionName = Uuid(); const params = { RoleArn: roleArn, RoleSessionName: roleSessionName,
+ 12 other calls in file
44 45 46 47 48 49 50 51 52 53 54 55 56
const chime = new AWS.Chime({region: 'us-east-1'}); const mediaPipeLineInit = new AWS.ChimeSDKMediaPipelines({region: 'us-east-1'}); chime.endpoint = new AWS.Endpoint('https://service.chime.aws.amazon.com/console'); mediaPipeLineInit.endpoint = new AWS.Endpoint('https://service.chime.aws.amazon.com/console'); const sts = new AWS.STS({region: 'us-east-1'}) console.log('STS: __________________________________', sts) if (isProduction) {
+ 4 other calls in file
aws-sdk.S3 is the most popular function in aws-sdk (7245 examples)