Assume 可能な S3FullAccess を持つロールを CloudFormation で作る

メモ

参考

テンプレート

信頼するユーザーの Arn をカンマ区切りで入力します。

AWSTemplateFormatVersion: "2010-09-09"
Description: "This Template Create A Role What Is Attached 'S3FullAccessRole'. Set Some 'User Arn' for Users To Assume This Role."
Parameters:
  UserArn:
    Description: "User Arn"
    Type: CommaDelimitedList
    Default: "arn:aws:iam::123456789012:root,arn:aws:iam::123456789012:user/userhoge,arn:aws:iam::123456789012:user/userfuga"
Resources:
  AssumableS3FullAccessRole:
    Type: AWS::IAM::Role
    Properties:
      # 信頼ポリシーの定義
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action:
              - sts:AssumeRole
            Principal:
              AWS: !Ref UserArn
      # インラインポリシーを定義
      Policies:
        - PolicyName: AmazonS3FullAccess
          PolicyDocument: 
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - "s3:*"
                  - "s3-object-lambda:*"
                Resource: "*"
      RoleName: AssumableS3FullAccessRoleForAwsUser