【问题标题】:How to set user name and group name in IAM using CloudFormation?如何使用 CloudFormation 在 IAM 中设置用户名和组名?
【发布时间】:2013-04-17 14:21:04
【问题描述】:

我创建了一个 CloudFormation 模板并且我想创建 IAM 用户,为此我使用了这个 JSON 字符串:

"CFNUser" : {
  "Type" : "AWS::IAM::User",
  "Properties" : {
    "LoginProfile": {
      "Password": { "Ref" : "AdminPassword" }
    }
  }
},

然后对于我使用的组:

"CFNUserGroup" : {
  "Type" : "AWS::IAM::Group"
},

创建堆栈后,我得到以下信息:

用户名 - IAMUsers-CFNUser-E1BT342YK7G6

组名称 - IAMUsers-CFNUserGroup-1UBUBRYALTIMI

所以我的问题是,如何在这里设置用户名?组名也一样?

【问题讨论】:

    标签: amazon-cloudformation amazon-iam


    【解决方案1】:

    在与一位 AWS 支持人员交谈后,在撰写本文时,无法使用 CloudFormation 模板在 IAM 中指定您自己的用户名和组名:-(

    也许他们不允许用户这样做是有原因的......无论如何,我能回答这个问题是件好事,如果有人觉得这很有用,我会很高兴。

    【讨论】:

    • 它不是很漂亮,但我认为这是为了在使用多个CloudFormation堆栈时确保唯一性。您可以将资源名称“CFNUserGroup”更改为您喜欢的任何字符串,但如果控制台至少为名称提供更多空间会很好。
    【解决方案2】:

    亚马逊从 2016 年 7 月 20 日起增加了支持。 https://aws.amazon.com/about-aws/whats-new/2016/07/aws-cloudformation-adds-support-for-aws-iot-and-additional-updates/

    {
      "Type": "AWS::IAM::User",
      "Properties": {
        "Groups": [ String, ... ],
        "LoginProfile": LoginProfile Type,
        "ManagedPolicyArns": [ String, ... ],
        "Path": String,
        "Policies": [ Policies, ... ],
        "UserName": String
      }
    }
    

    【讨论】:

      【解决方案3】:

      对于组,它是 GroupName 属性:

          "CFNUserGroup" : {
             "Type" : "AWS::IAM::Group",
             "Properties": {
                "GroupName": "My_CFN_User_Group"
              }
           }

      【讨论】:

        猜你喜欢
        • 2021-06-21
        • 2020-10-22
        • 1970-01-01
        • 2015-10-22
        • 1970-01-01
        • 1970-01-01
        • 2017-07-07
        • 2021-10-15
        • 2015-12-03
        相关资源
        最近更新 更多