2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AWS Rust SDKを使ってAssume Roleする方法

Posted at
use aws_config::default_provider::credentials::DefaultCredentialsChain;
use aws_config::sts::AssumeRoleProvider;
use aws_types::region::Region;

#[tokio::main]
async fn main() {
    let credentials_provider = DefaultCredentialsChain::builder().build().await;

    let assume_role_arn = "TARGET_ROLE_ARN";

    let assume_role_provider = AssumeRoleProvider::builder(assume_role_arn)
        .region(Region::new("ap-northeast-1"))
        .build(credentials_provider);

    let aws_config = aws_config::from_env()
        .region("ap-northeast-1")
        .credentials_provider(assume_role_provider)
        .load()
        .await;

    let client = aws_sdk_route53::Client::new(&aws_config);

    let hosted_zones = client.list_hosted_zones().send().await.unwrap();

    for hz in hosted_zones.hosted_zones.unwrap() {
        println!("{}", hz.name.unwrap());
    }
}

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?