amazon-web-services - 使用 cloudformation 创建 AWS IAM 策略

标签 amazon-web-services aws-cloudformation amazon-iam

我有一个已创建的 IAM 角色(MyIAMrole)。我想使用 Cloudformation 模板将策略附加到此角色。

"Mypolicy":{
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyName": "assume-role-policy",
        "PolicyDocument": {
          "Version" : "2012-10-17",
        "Statement": [
        { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "*" }
      ]
    },
    "Roles": [ { "Ref": "arn:aws:iam::*:role/MyIAMrole" } ]
  }
}

当我尝试验证这一点时,我收到一条错误消息“未解析的引用选项”。

如何将此策略附加到现有角色?

最佳答案

我设法通过引用角色的名称而不是 ARN 让您的代码片段正常工作。

根据 AWS::IAM::Policy documentation :

Roles: The names of AWS::IAM::Roles to which this policy will be attached.

但是,当堆栈转到 CREATE_COMPLETE 时,我看不到 IAM 的“策略”部分中列出的策略,也看不到附加到引用角色的策略。

您可能无法使用 CloudFormation 将策略附加到现有角色。可能。您可能需要创建角色作为 CloudFormation 模板的一部分才能附加角色。

关于amazon-web-services - 使用 cloudformation 创建 AWS IAM 策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47048061/

相关文章:

amazon-web-services - CDK : Template format error: Parameter count 63 is greater than max allowed 60

amazon-web-services - AWS::EC2::SubnetRouteTableAssociation 未出现在 CloudFormation Designer 的资源类型 Pane 中

amazon-web-services - 如何限制 AWS API Gateway 对特定 CloudFront 分配或 Route53 子域的访问

aws-cloudformation - 在 CloudFormation 中为 AWS Load Balancer v2 配置连接耗尽

ruby-on-rails - 如何为Hartl的Rails教程授予AWS用户权限

amazon-web-services - 无服务器部署 lambda 无法承担现有 IAM 角色

从 S3 URI 中选取 S3 存储桶名称的正则表达式

amazon-web-services - 需要 AWS cloudformation 模板或引导脚本帮助

amazon-web-services - 使用查询字符串身份验证和 .Net SDK 的 Amazon S3 分段上传

amazon-web-services - AWS 自动同步 : moving data from FTP server to S3