use of software.amazon.awssdk.services.s3.model.PutBucketPolicyRequest in project aws-doc-sdk-examples by awsdocs.
the class SetBucketPolicy method setPolicy.
// snippet-start:[s3.java2.set_bucket_policy.main]
public static void setPolicy(S3Client s3, String bucketName, String policyText) {
System.out.println("Setting policy:");
System.out.println("----");
System.out.println(policyText);
System.out.println("----");
System.out.format("On Amazon S3 bucket: \"%s\"\n", bucketName);
try {
PutBucketPolicyRequest policyReq = PutBucketPolicyRequest.builder().bucket(bucketName).policy(policyText).build();
s3.putBucketPolicy(policyReq);
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
System.out.println("Done!");
}
use of software.amazon.awssdk.services.s3.model.PutBucketPolicyRequest in project aws-doc-sdk-examples by awsdocs.
the class DemoUtils method ensurePersonalizePermissionsOnS3Bucket.
public static void ensurePersonalizePermissionsOnS3Bucket(S3Client s3, String bucket) {
final String bucketPolicy = BUCKET_POLICY_TEMPLATE.replace("{bucket}", bucket);
// System.out.println("Bucket policy: " + bucketPolicy);
PutBucketPolicyRequest policyRequest = PutBucketPolicyRequest.builder().bucket(bucket).policy(bucketPolicy).build();
s3.putBucketPolicy(policyRequest);
}
Aggregations