- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 python 和 boto3 列出我的组织拥有的资源。我毫无问题地列出了主帐户中的资源,但我还需要列出子帐户中的资源。我可以获得 child 帐户 ID,但仅此而已。
有什么帮助吗?
最佳答案
您将需要访问属于 child 帐户的一组凭据。
来自Accessing and Administering the Member Accounts in Your Organization - AWS Organizations :
When you create a member account using the AWS Organizations console, AWS Organizations automatically creates an IAM role in the account. This role has full administrative permissions in the member account. The role is also configured to grant that access to the organization's master account.
To use this role to access the member account, you must sign in as a user from the master account that has permissions to assume the role.
因此,您可以在子账户中承担 IAM 角色,然后该角色会提供一组临时凭证,这些凭证可与 boto3
一起使用来对子账户进行 API 调用 child 帐户。
import boto3
role_info = {
'RoleArn': 'arn:aws:iam::<AWS_ACCOUNT_NUMBER>:role/<AWS_ROLE_NAME>',
'RoleSessionName': '<SOME_SESSION_NAME>'
}
client = boto3.client('sts')
credentials = client.assume_role(**role_info)
session = boto3.session.Session(
aws_access_key_id=credentials['Credentials']['AccessKeyId'],
aws_secret_access_key=credentials['Credentials']['SecretAccessKey'],
aws_session_token=credentials['Credentials']['SessionToken']
)
一种更简单的方法是将角色作为新配置文件放入 .aws/config
文件中。然后,您可以在进行函数调用时指定配置文件:
# In ~/.aws/credentials:
[master]
aws_access_key_id=foo
aws_secret_access_key=bar
# In ~/.aws/config
[profile child1]
role_arn=arn:aws:iam:...
source_profile=master
像这样使用它:
session = boto3.session.Session(profile_name='dev')
s3 = session.client('s3')
参见:How to choose an AWS profile when using boto3 to connect to CloudFront
关于python - 使用 boto3 列出主帐户中子帐户的资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56744368/
我正在使用 Make,并且有一个 makefile,它设置了一个变量,该变量的值需要我从父 makefile 覆盖。我尝试在父 makefile 中设置变量并使用 export 将其传递给子 make
全屏运行下面的代码片段并调整屏幕大小以查看最后一行中的图像如何堆叠/环绕。它们直接包裹在下一行的正中央。我希望它们向左环绕。 #instafeed{ text-align: center; } #
我在这个网站上找到了以下 jsfiddle,它 90% 回答了我的查询。 JSFiddle 但是我希望能够在内部 div 上包含边距。我已经尝试修改计算以考虑边距,但如果内部 div 不换行或溢出,我
我有 div(class name:xyz) 在其中插入小的 4 div (class name:ax )。我需要垂直插入前两个 div,第三个应该水平插入第一个,第四个应该垂直插入第三个。但是所有的
我有一些动态添加的 QWidgets,我想在它们发生变化时执行一些任务。 我想我不能使用 connect() 因为我还需要触发更改的 QWidget 的名称。 我如何才能同时查看更改了哪个 QWidg
我想在子操作中生成 HTML head 部分;而该页面还有许多其他子操作。 html head 部分取决于其他操作来确定应包含哪些 js/css 文件。不同的子 Action 可以共享同一个js/cs
我正在构建一个 Angular 7 应用程序。我想获取父 div 中某个 div 的“索引”或行。 我的标记如下所示: 我知道如果标记如下所示,我可以轻松做到这一点,但如果
如果我在 Ruby 中调用系统方法,它将在子 shell 中执行我的命令并输出它可以输出的所有内容。因此,如果我将其放入 file.rb 中: system 'vim' 然后运行 $ ruby
我可以对齐两个 div只需设置他们的 display至 inline-block并使用相同的 line-height如下图所示: 但是,我想要的是根据内部 div 的基线对齐两个嵌套 div,如下所示
我的父 Controller 上有一些属性,我希望我的子 Controller 可以访问这些属性。 我想像这样访问它: App.ApplicationController = Ember.Object
我有一个容器 div,里面有一个 SVG: 以及以下 CSS: svg { width: 100%; height: 1
我必须处理的事件目录是这样布置的:域包含许多 OU。这些 OU 之一被命名为“主 OU”。在这个 OU 中,有几个以全局办事处位置命名的 OU(即“芝加哥”“巴黎”)。 任何实际有血有肉的用户帐户都被
我在 NSBox 中有一个 NSTextView。我想每当 NSTextView 获得焦点时在 NSBox 周围绘制焦点环,并在 NSTextView 失去焦点时立即删除焦点环。 谢谢 最佳答案 为此
在下面的代码中,我有一个链接,其 div id 是“my-acc-hover-container”。当用户将鼠标悬停在该链接上时,一个新的部分将向下滑动,其中包含“Hello Guest”和“Logi
我正在使用 javafx 创建一个像 sqlyog 这样的应用程序。我的问题是我想添加数据库。无论何时添加,它都应该更新具有所有其他数据库的 TreeView 。出现创建数据库的对话框,给出名称并设置
我的 UIScrollView 中有几个屏幕的内容,它只能垂直滚动。 我想以编程方式滚动到包含在其层次结构中某处的 View 。 UIScrollView 移动以便 subview 位于 UIScro
我想更新已创建端口的 vif_model。我在 CLI 中使用以下命令 neutron port-update --binding:vif_model=avp 如何使用 neutron 的 pyth
我在一个程序中有两个查询。 查询1:我正在尝试在容器 div 的子 div 内水平对齐两个子 super 子分区。下面是我的代码,你能帮我解决这个问题吗?我已附上所需的输出。 查询2:从代码中你可以看
我在一个程序中有两个查询。 查询1:我正在尝试在容器 div 的子 div 内水平对齐两个子 super 子分区。下面是我的代码,你能帮我解决这个问题吗?我已附上所需的输出。 查询2:从代码中你可以看
我是一名优秀的程序员,十分优秀!