【发布时间】:2020-11-02 10:56:47
【问题描述】:
我在账户 B 中有 S3 存储桶“跨存储桶”。现在我希望账户 A 中的 EC2 访问账户 B 中的这个存储桶“跨存储桶”。
我需要使用 IAM 角色来实现这一点,因为我们不允许创建用户。
我已使用以下模板在帐户 B 中创建角色
AWSTemplateFormatVersion : '2010-09-09'
Description: 'Cross account role for S3'
Parameters:
AccountId:
Type: String
Description: Account ID of admin account (containing user to allow)
Resources:
CrossAccountRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Action: sts:AssumeRole
Principal:
AWS:
- !Sub arn:aws:iam::${AccountId}:root
Path: /
Policies:
- PolicyName: my-s3-delegate
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:ListBucket
- s3:GetObject
Resource: "*"
RootInstanceProfile:
Type: "AWS::IAM::InstanceProfile"
Properties:
Path: "/"
Roles:
-
Ref: "CrossAccountRole"
创建此角色后,我应该如何将其附加到帐户 A 中的实例? 或者我在这里遗漏了什么?
【问题讨论】:
-
拥有
Account A受信任的帐户B?你可以在这里找到教程:docs.aws.amazon.com/IAM/latest/UserGuide/…
标签: amazon-web-services amazon-s3 amazon-cloudformation amazon-iam