Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit 07521d4

Browse files
Adding --workers flag in the cli
1 parent c89987c commit 07521d4

File tree

6 files changed

+32
-4
lines changed

6 files changed

+32
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-sso-rs"
3-
version = "1.4.0"
3+
version = "1.5.0"
44
edition = "2021"
55
authors = ["containerscrew info@containerscrew.com"]
66
rust-version = "1.88.0"

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</p>
66

77
---
8+
89
![Rust](https://img.shields.io/badge/rust-%23000000.svg?style=for-the-badge&logo=rust&logoColor=white)
910
[![License - MIT](https://img.shields.io/github/license/containerscrew/aws-sso-rs)](/LICENSE)
1011
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
@@ -16,7 +17,9 @@
1617
[![GitHub Releases Stats](https://img.shields.io/github/downloads/containerscrew/aws-sso-rs/total.svg?logo=github)](https://somsubhra.github.io/github-release-stats/?username=containerscrew&repository=aws-sso-rs)
1718
![Crates.io Downloads (recent)](https://img.shields.io/crates/dr/aws-sso-rs?style=flat&label=crates.io%20Downloads)
1819
![Crates.io Version](https://img.shields.io/crates/v/aws-sso-rs)
20+
1921
---
22+
2023
<p align="center">
2124
<h3 align="center">$ aws-sso-rs </h3>
2225
<img src="./assets/example-1.png" alt="example"/>
@@ -85,8 +88,8 @@ cargo build --release
8588
aws-sso-rs --start-url https://mycompany.awsapps.com/start --aws-region eu-west-1
8689
```
8790

88-
* `--start-url` is the URL of your AWS SSO endpoint, which you can find in your AWS SSO console.
89-
* `--aws-region` is the AWS region where your SSO is configured, e.g., `eu-west-1`, `us-east-1`, etc.
91+
- `--start-url` is the URL of your AWS SSO endpoint, which you can find in your AWS SSO console.
92+
- `--aws-region` is the AWS region where your SSO is configured, e.g., `eu-west-1`, `us-east-1`, etc.
9093

9194
> [!NOTE]
9295
> This command will open your default browser. You will need to approve manually the authentication.
@@ -136,6 +139,16 @@ aws-sso-rs --start-url https://mycompany.awsapps.com/start --aws-region eu-west-
136139
aws-sso-rs --start-url https://mycompany.awsapps.com/start --aws-region eu-west-1 --log-level debug
137140
```
138141

142+
## Workers
143+
144+
If you have for example 40 accounts in your AWS organization, you can use the `--workers` flag to limit the number of concurrent tasks. This can help you avoid overwhelming the AWS API with too many requests (429) at once. More workers will speed up the process of fetching credentials for all accounts, but it may also lead to throttling if you set it too high.
145+
146+
```shell
147+
aws-sso-rs --start-url https://mycompany.awsapps.com/start --aws-region eu-west-1 -w 10
148+
```
149+
150+
> Default value is `5`, and the maximum value is `20`. You can change it by modifying the `--workers` flag.
151+
139152
# Switching `AWS_PROFILE` in your terminal
140153

141154
## Zsh/Bash shell

assets/example-1.png

11.3 KB
Loading

rust-toolchain.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[toolchain]
2+
channel = "1.88.0"
3+
components = [
4+
"clippy-preview",
5+
"rustfmt-preview",
6+
]

src/cli.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ pub struct Args {
5353
required = false
5454
)]
5555
pub account_overrides: Option<Vec<(String, String)>>,
56+
#[arg(
57+
short = 'w',
58+
long = "workers",
59+
help = "Number of max tasks (threads) to run in parallel.",
60+
default_value_t = 5,
61+
value_parser(clap::value_parser!(u8).range(1..=20)),
62+
required = false
63+
)]
64+
pub workers: u8,
5665
}
5766

5867
fn parse_key_val_string(s: &str) -> Result<(String, String), String> {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
101101
);
102102

103103
// Limit the number of concurrent tasks to avoid overwhelming the API
104-
let semaphore = Arc::new(Semaphore::new(12));
104+
let semaphore = Arc::new(Semaphore::new(cli.workers as usize));
105105

106106
// Iterate over all accounts and get credentials for each account
107107
for account in account_list {

0 commit comments

Comments
 (0)