2023-01-27 08:32:21 -05:00
# AWS STS code examples for the SDK for JavaScript (v3)
2021-12-06 19:28:35 +00:00
2023-01-24 14:48:52 -05:00
## Overview
2021-12-06 19:28:35 +00:00
2024-01-04 12:50:33 -05:00
Shows how to use the AWS SDK for JavaScript (v3) to work with AWS Security Token Service (AWS STS).
2021-12-06 19:28:35 +00:00
2024-01-04 12:50:33 -05:00
<!--custom.overview.start-->
<!--custom.overview.end-->
2021-12-06 19:28:35 +00:00
2024-01-04 12:50:33 -05:00
_ AWS STS creates and provides trusted users with temporary security credentials that can control access to your AWS resources. _
2021-12-06 19:28:35 +00:00
2024-01-04 12:50:33 -05:00
## ⚠ Important
2024-01-09 12:33:12 -05:00
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing ](https://aws.amazon.com/pricing/ ) and [Free Tier ](https://aws.amazon.com/free/ ).
2024-01-04 12:50:33 -05:00
* Running the tests might result in charges to your AWS account.
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege ](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege ).
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services ](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services ).
<!--custom.important.start-->
<!--custom.important.end-->
2023-01-24 14:48:52 -05:00
## Code examples
2024-01-04 12:50:33 -05:00
### Prerequisites
For prerequisites, see the [README ](../../README.md#Prerequisites ) in the `javascriptv3` folder.
<!--custom.prerequisites.start-->
<!--custom.prerequisites.end-->
2023-01-24 14:48:52 -05:00
### Single actions
2021-12-06 19:28:35 +00:00
2023-01-24 14:48:52 -05:00
Code excerpts that show you how to call individual service functions.
2024-04-30 12:22:08 -07:00
- [AssumeRole ](libs/client.js#L4 )
2023-01-24 14:48:52 -05:00
2021-12-06 19:28:35 +00:00
2024-01-04 12:50:33 -05:00
<!--custom.examples.start-->
<!--custom.examples.end-->
2023-01-24 14:48:52 -05:00
2024-01-04 12:50:33 -05:00
## Run the examples
2023-01-24 14:48:52 -05:00
### Instructions
2024-01-04 12:50:33 -05:00
**Note ** : All code examples are written in ECMAscript 6 (ES6). For guidelines on converting to CommonJS, see
[JavaScript ES6/CommonJS syntax ](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/sdk-examples-javascript-syntax.html ).
2023-01-24 14:48:52 -05:00
**Run a single action **
2024-01-04 12:50:33 -05:00
``` bash
node ./actions/<fileName>
```
2023-01-24 14:48:52 -05:00
2024-01-04 12:50:33 -05:00
**Run a scenario **
2024-08-28 14:08:16 -04:00
2024-01-04 12:50:33 -05:00
Most scenarios can be run with the following command:
``` bash
node ./scenarios/<fileName>
```
2023-01-24 14:48:52 -05:00
2024-08-28 14:08:16 -04:00
**Run with options **
Some actions and scenarios can be run with options from the command line:
``` bash
node ./scenarios/<fileName> --option1 --option2
```
[util.parseArgs ](https://nodejs.org/api/util.html#utilparseargsconfig ) is used to configure
these options. For the specific options available to each script, see the `parseArgs` usage
for that file.
2024-01-04 12:50:33 -05:00
<!--custom.instructions.start-->
<!--custom.instructions.end-->
2023-01-24 14:48:52 -05:00
2024-01-04 12:50:33 -05:00
### Tests
⚠ Running tests might result in charges to your AWS account.
To find instructions for running these tests, see the [README ](../../README.md#Tests )
in the `javascriptv3` folder.
<!--custom.tests.start-->
<!--custom.tests.end-->
2023-01-24 14:48:52 -05:00
## Additional resources
2024-01-04 12:50:33 -05:00
- [AWS STS User Guide ](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html )
- [AWS STS API Reference ](https://docs.aws.amazon.com/STS/latest/APIReference/welcome.html )
- [SDK for JavaScript (v3) AWS STS reference ](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sts )
<!--custom.resources.start-->
<!--custom.resources.end-->
---
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2023-01-24 14:48:52 -05:00
2024-01-04 12:50:33 -05:00
SPDX-License-Identifier: Apache-2.0