如何使用cloudformation创建具有s3权限的IAM用户?

时间:2019-06-26 21:40:22

标签: amazon-web-services amazon-s3 amazon-cloudformation

我需要使用cloudformation创建一个具有s3权限的IAM用户。

我还没有找到解决方法

2 个答案:

答案 0 :(得分:4)

使用AWS::IAM::User创建IAM用户。

这是一个使用托管策略的YAML模板:

  DeveloperUser:
    Type: 'AWS::IAM::User'
    Properties:
      UserName: user-developer
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/AWSServiceCatalogEndUserFullAccess'
        - 'arn:aws:iam::aws:policy/ReadOnlyAccess'
        - 'arn:aws:iam::aws:policy/CloudWatchFullAccess'
        - 'arn:aws:iam::aws:policy/AmazonVPCFullAccess'
        - 'arn:aws:iam::aws:policy/AmazonS3FullAccess'

这是具有内联权限的JSON策略:

      "User":{
         "Type":"AWS::IAM::User",
         "Properties":{
            "Policies":[
               {
                  "PolicyName":"S3",
                  "PolicyDocument":{
                     "Statement":[
                        {
                           "Effect":"Allow",
                           "Action":[
                              "s3:*",
                           ],
                           "Resource":[
                              "arn:aws:s3:::my-bucket",
                              "arn:aws:s3:::my-bucket/*"
                           ]
                        }
                     ]
                  }
               }
            ]
         }
      }

答案 1 :(得分:-1)

您可以尝试https:krunal4amity.github.io。它是一个在线aws cloudformation模板生成器。生成模板需要大量的人工工作和时间。