
上QQ阅读APP看书,第一时间看更新
Adding a group policy – Inline
Add inline policy under the group. If the same policy name is available under the group, it will update it:
String inlineGroupPolicyName = "S3FullAccessOnMyBucket2";
String inlineGroupPolicyDocument = readFromFile("NewPolicyDocument.json");
putGroupPolicy(groupName, inlineGroupPolicyName, inlineGroupPolicyDocument); ........ public void putGroupPolicy(
String groupName,
String policyName,
String policyDocument) {
PutGroupPolicyRequest putGroupPolicyRequest =
new PutGroupPolicyRequest()
.withGroupName(groupName)
.withPolicyName(policyName)
.withPolicyDocument(policyDocument);
PutGroupPolicyResult putGroupPolicyResult =
amazonIdentityManagement.
putGroupPolicy(putGroupPolicyRequest);
}
NewPolicyDocument.json
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": "arn:aws:s3:::my-bucket-2"
}]
}