Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i create an IAM user with s3 permission using cloudformation?

Tags:

I need to create an IAM user with s3 permissions using cloudformation.

I havent found a solution

like image 875
Eniayomi Avatar asked Jun 26 '19 21:06

Eniayomi


1 Answers

Use AWS::IAM::User to create the IAM User.

Here's a YAML template that uses Managed Policies:

  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'

Here's a JSON policy that has inline permissions:

      "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/*"
                           ]
                        }
                     ]
                  }
               }
            ]
         }
      }
like image 71
John Rotenstein Avatar answered Nov 15 '22 04:11

John Rotenstein