[英]Acquiring aws cross account iam role locally
I'm new to aws and facing problem for iam role.I'm doing cross account role. 我是AWS新手,并且面临IAM角色的问题。我正在做跨帐户角色。 Say in Account x ,created role for Account Y togive permission to read from kinesis Streams. 在帐户x中说,为帐户Y创建了授予从kinesis Streams读取的权限的角色。
I want to connect to Account Y to fetch streams from Account X locally using java SDK(i'm not launching EC2 instance on Account Y). 我想连接到帐户Y,以使用Java SDK从帐户X本地获取流(我没有在帐户Y上启动EC2实例)。 So is their any way to do that? 那么他们有什么办法吗?
I understand that if i run the application on EC2 instance on Account Y, I will be able to fectch it, but i don't want to fetch it by using EC2. 我了解,如果我在帐户Y的EC2实例上运行该应用程序,则可以完成该应用程序,但我不想使用EC2来获取它。
AWS doc mentions in
https://docs.aws.amazon.com/cli/latest/topic/config-vars.html
# In ~/.aws/credentials:
[development]
aws_access_key_id=foo
aws_secret_access_key=bar
# In ~/.aws/config
[profile crossaccount]
role_arn=arn:aws:iam:...
source_profile=development
Is it related to that? 与此有关吗? Here i think crossaccount is the role created in account x to give access to account y. 在这里,我认为交叉帐户是在帐户x中创建的角色,用于访问帐户y。
Which aws api should I call to fetch the streams?
Thanks in advance. 提前致谢。
Cross-Account access in AWS has a specific protocol you'll need to follow. AWS中的跨账户访问具有您需要遵循的特定协议。 As you created an IAM Role in account X which has been given access to resources in account Y, account Y will also need to grant that role permission to perform STS:AssumeRole
. 当您在帐户X中创建了一个IAM角色(该帐户已获得对帐户Y中资源的访问权限)时,帐户Y还需要授予该角色权限以执行STS:AssumeRole
。
Once this part of setup is complete you should be good to go. 一旦这部分设置完成,您就应该做好了。 Read more about it here 在这里了解更多
To use the AWS SDK for Java, create a service object for the STS
service and perform an AssumeRole
invocation. 要使用适用于Java的AWS开发工具包,请为STS
服务创建服务对象,然后执行AssumeRole
调用。 If you supply this with the right credentials, the result of that will be a valid pair of credentials that have access to account Y's resources. 如果为您提供正确的凭据,则结果将是一对有效的凭据,可以访问帐户Y的资源。
Read more about using Assume Role in Java here . 在此处阅读有关在Java中使用角色角色的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.