S3 Batch Operations를 사용하여 S3 Object Lock 법적 보존 해제 - Amazon Simple Storage Service

S3 Batch Operations를 사용하여 S3 Object Lock 법적 보존 해제

다음 예제는 신뢰 정책을 생성하고 S3 배치 작업 및 S3 객체 잠금 구성 권한을 설정하는 이전 예제를 기반으로 합니다. 이 예제에서는 Batch Operations를 사용하여 객체에 대한 Object Lock 법적 보존을 비활성화하는 방법을 보여줍니다.

이 예제에서는 먼저 역할을 업데이트하여 s3:PutObjectLegalHold 권한을 부여하고, 매니페스트에서 식별된 객체의 법적 보존을 해제(제거)하는 배치 작업을 생성한 다음 보고합니다.

다음 예제를 사용하려면 user input placeholders를 사용자의 정보로 대체합니다.

다음 AWS CLI 예제에서는 Batch Operations를 사용하여 여러 객체에서 S3 Object Lock의 법적 보존을 해제하는 방법을 보여줍니다.

예 - s3:PutObjectLegalHold 권한을 부여하도록 역할 업데이트
export AWS_PROFILE='aws-user' read -d '' legal_hold_permissions <<EOF { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObjectLegalHold" ], "Resource": [ "arn:aws:s3:::amzn-s3-demo-manifest-bucket/*" ] } ] EOF aws iam put-role-policy --role-name batch_operations-objectlock --policy-name legal-hold-permissions --policy-document "${legal_hold_permissions}"
예 - 법적 보존 해제

다음 예제에서는 법적 보존을 해제합니다.

export AWS_PROFILE='aws-user' export AWS_DEFAULT_REGION='us-west-2' export ACCOUNT_ID=123456789012 export ROLE_ARN='arn:aws:iam::123456789012:role/batch_operations-objectlock' read -d '' OPERATION <<EOF { "S3PutObjectLegalHold": { "LegalHold": { "Status":"OFF" } } } EOF read -d '' MANIFEST <<EOF { "Spec": { "Format": "S3BatchOperations_CSV_20180820", "Fields": [ "Bucket", "Key" ] }, "Location": { "ObjectArn": "arn:aws:s3:::amzn-s3-demo-manifest-bucket/legalhold-object-manifest.csv", "ETag": "Your-manifest-ETag" } } EOF read -d '' REPORT <<EOF { "Bucket": "arn:aws:s3:::amzn-s3-demo-completion-report-bucket", "Format": "Report_CSV_20180820", "Enabled": true, "Prefix": "reports/legalhold-objects-batch_operations", "ReportScope": "AllTasks" } EOF aws \ s3control create-job \ --account-id "${ACCOUNT_ID}" \ --manifest "${MANIFEST//$'\n'}" \ --operation "${OPERATION//$'\n'/}" \ --report "${REPORT//$'\n'}" \ --priority 10 \ --role-arn "${ROLE_ARN}" \ --client-request-token "$(uuidgen)" \ --region "${AWS_DEFAULT_REGION}" \ --description "Turn off legal hold";

다음 AWS SDK for Java 예제에서는 Batch Operations를 사용하여 여러 객체에서 S3 Object Lock의 법적 보존을 해제하는 방법을 보여줍니다.

예 - s3:PutObjectLegalHold 권한을 부여하도록 역할 업데이트
public void allowPutObjectLegalHold() { final String roleName = "batch_operations-object-lock"; final String legalHoldPermissions = "{" + " \"Version\": \"2012-10-17\"," + " \"Statement\": [" + " {" + " \"Effect\": \"Allow\"," + " \"Action\": [" + " \"s3:PutObjectLegalHold\"" + " ]," + " \"Resource\": [" + " \"arn:aws:s3:::amzn-s3-demo-manifest-bucket/*\"" + " ]" + " }" + " ]" + "}"; final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient(); final PutRolePolicyRequest putRolePolicyRequest = new PutRolePolicyRequest() .withPolicyDocument(legalHoldPermissions) .withPolicyName("legal-hold-permissions") .withRoleName(roleName); final PutRolePolicyResult putRolePolicyResult = iam.putRolePolicy(putRolePolicyRequest); }
예 - 법적 보존 해제

법적 보존을 해제하려면 아래 예제를 사용하세요.

public String createLegalHoldOffJob(final AWSS3ControlClient awss3ControlClient) { final String manifestObjectArn = "arn:aws:s3:::amzn-s3-demo-manifest-bucket/legalhold-object-manifest.csv"; final String manifestObjectVersionId = "15ad5ba069e6bbc465c77bf83d541385"; final JobManifestLocation manifestLocation = new JobManifestLocation() .withObjectArn(manifestObjectArn) .withETag(manifestObjectVersionId); final JobManifestSpec manifestSpec = new JobManifestSpec() .withFormat(JobManifestFormat.S3BatchOperations_CSV_20180820) .withFields("Bucket", "Key"); final JobManifest manifestToPublicApi = new JobManifest() .withLocation(manifestLocation) .withSpec(manifestSpec); final String jobReportBucketArn = "arn:aws:s3:::amzn-s3-demo-completion-report-bucket"; final String jobReportPrefix = "reports/legalhold-objects-batch_operations"; final JobReport jobReport = new JobReport() .withEnabled(true) .withReportScope(JobReportScope.AllTasks) .withBucket(jobReportBucketArn) .withPrefix(jobReportPrefix) .withFormat(JobReportFormat.Report_CSV_20180820); final JobOperation jobOperation = new JobOperation() .withS3PutObjectLegalHold(new S3SetObjectLegalHoldOperation() .withLegalHold(new S3ObjectLockLegalHold() .withStatus(S3ObjectLockLegalHoldStatus.OFF))); final String roleArn = "arn:aws:iam::123456789012:role/batch_operations-object-lock"; final Boolean requiresConfirmation = true; final int priority = 10; final CreateJobRequest request = new CreateJobRequest() .withAccountId("123456789012") .withDescription("Turn off legal hold") .withManifest(manifestToPublicApi) .withOperation(jobOperation) .withPriority(priority) .withRoleArn(roleArn) .withReport(jobReport) .withConfirmationRequired(requiresConfirmation); final CreateJobResult result = awss3ControlClient.createJob(request); return result.getJobId(); }