Amazon Web Services Bootcamp
上QQ阅读APP看书,第一时间看更新

Creating an inline role policy

The following command creates an inline role policy. Inline role policies will be specific to this role only; we cannot reuse this policy:

    aws iam put-role-policy ^
    --role-name "AmazonS3FullAccessRole" ^
    --policy-name "S3FullAccessOnMyBucket2" ^
    --policy-document file://NewPolicyDocument.json  

The following is the policy document used to create the inline role policy named NewPolicyDocument.json:

{ 
  "Version": "2012-10-17", 
  "Statement": [{ 
    "Effect": "Allow", 
    "Action": [ 
      "s3:*" 
    ], 
    "Resource": "arn:aws:s3:::my-bucket-2" 
  }] 
} 

The following are the options, which can be used with put-role-policy:

Parameters

Optional

Description

--role-name

False

This is the role name to which the inline policy will be created

--policy-name

False

This is a friendly name for the policy

--policy-document

False

This is the policy JSON document that defines permissions to AWS services