简体   繁体   English

在 Eclipse 2.0 的 aws 工具包中承担/切换角色

[英]Assume/switch role in aws toolkit for eclipse 2.0

I am using aws toolkit for eclipse 2.0.我正在为 Eclipse 2.0 使用 aws 工具包。 using the options ( window -> preference -> aws toolkit) I have configured IAM/login user api access key id and secret access key.使用选项(窗口 -> 首选项 -> aws 工具包)我已经配置了 IAM/登录用户 api 访问密钥 ID 和秘密访问密钥。 According to our aws configuration, this IAM user has to assume role to view/access any resources in our environment.根据我们的 aws 配置,此 IAM 用户必须承担角色才能查看/访问我们环境中的任何资源。 I am doing it using aws cli with "–-profile " option.我正在使用带有“–-profile”选项的 aws cli 来执行此操作。 How to do the same thing in aws toolkit for eclipse ?如何在 aws toolkit for eclipse 中做同样的事情?

Looks like I figured it out with help from an AWS expert.看起来我是在 AWS 专家的帮助下弄明白的。 Basically you do 2 things:基本上你要做两件事:

  1. generate an AWS STS session token生成 AWS STS 会话令牌
  2. use the "session token" values in your IDE.在您的 IDE 中使用“会话令牌”值。

Example: aws sts assume-role --role-arn "value" --role-session-name "value" --duration-seconds "value"示例:aws sts 假设角色 --role-arn "value" --role-session-name "value" --duration-seconds "value"

put in the values generated for these in your eclipse IDE AWS profile:将为这些生成的值放入您的 Eclipse IDE AWS 配置文件中:

    AccessKeyId
    SecretAccessKey
    SessionToken

You can also use a SAML assertion by using this command on the AWS CLI您还可以通过在 AWS CLI 上使用此命令来使用 SAML 断言

aws sts assume-role-with-saml --role-arn "value" --principal-arn "value" --saml-assertion "value" 

Note: the max session length is defined by the role you're using.注意:最大会话长度由您使用的角色定义。

In order to switch the account you will need to to add the below to your credentials file:为了切换帐户,您需要将以下内容添加到您的凭据文件中:

[regular]
aws_access_key_id = xxxxxxxxxxxxxxxxx
aws_secret_access_key = xxxxxxxxxxxx

[dev]
source_profile = regular
role_arn = arn:aws:iam::123456789123:role/RoleName

Once you do that, using AWS Toolkit, you can select "dev" profile and that's it!完成后,使用 AWS Toolkit,您可以选择“dev”配置文件,就是这样!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM