레이블 지정에 작업 태그를 사용하는 배치 작업 생성 - Amazon Simple Storage Service

레이블 지정에 작업 태그를 사용하는 배치 작업 생성

태그를 추가하여 S3 배치 작업 건에 대한 레이블을 지정하고 액세스를 제어할 수 있습니다. 태그는 배치 작업 건을 담당하는 사용자를 식별하는 데 사용할 수 있습니다. 태그가 연결된 작업을 생성할 수 있으며 작업을 생성한 후 작업에 태그를 추가할 수 있습니다. 자세한 내용은 태그를 사용하여 액세스 제어 및 작업 레이블 지정 섹션을 참조하세요.

다음 AWS CLI 예제에서는 작업 태그를 작업의 레이블로 사용하여 S3 배치 작업 S3PutObjectCopy 작업을 생성합니다.

  1. 배치 작업에서 수행하려는 작업 또는 OPERATION을 선택하고 TargetResource를 선택합니다.

    read -d '' OPERATION <<EOF { "S3PutObjectCopy": { "TargetResource": "arn:aws:s3:::destination-bucket" } } EOF
  2. 작업에 대해 원하는 작업 TAGS를 식별합니다. 이 경우 두 개의 태그 departmentFiscalYear를 각각 Marketing2020 값과 함께 적용합니다.

    read -d '' TAGS <<EOF [ { "Key": "department", "Value": "Marketing" }, { "Key": "FiscalYear", "Value": "2020" } ] EOF
  3. 배치 작업에 대해 MANIFEST를 지정합니다.

    read -d '' MANIFEST <<EOF { "Spec": { "Format": "EXAMPLE_S3BatchOperations_CSV_20180820", "Fields": [ "Bucket", "Key" ] }, "Location": { "ObjectArn": "arn:aws:s3:::example-bucket/example_manifest.csv", "ETag": "example-5dc7a8bfb90808fc5d546218" } } EOF
  4. 배치 작업에 대해 REPORT를 구성합니다.

    read -d '' REPORT <<EOF { "Bucket": "arn:aws:s3:::example-report-bucket", "Format": "Example_Report_CSV_20180820", "Enabled": true, "Prefix": "reports/copy-with-replace-metadata", "ReportScope": "AllTasks" } EOF
  5. create-job 작업을 실행하여 이전 단계에서 설정된 입력으로 배치 작업을 생성합니다.

    aws \ s3control create-job \ --account-id 123456789012 \ --manifest "${MANIFEST//$'\n'}" \ --operation "${OPERATION//$'\n'/}" \ --report "${REPORT//$'\n'}" \ --priority 10 \ --role-arn arn:aws:iam::123456789012:role/batch-operations-role \ --tags "${TAGS//$'\n'/}" \ --client-request-token "$(uuidgen)" \ --region us-west-2 \ --description "Copy with Replace Metadata";

다음 예제에서는 AWS SDK for Java를 사용하여 태그가 있는 S3 배치 작업을 생성합니다.

public String createJob(final AWSS3ControlClient awss3ControlClient) { final String manifestObjectArn = "arn:aws:s3:::example-manifest-bucket/manifests/10_manifest.csv"; final String manifestObjectVersionId = "example-5dc7a8bfb90808fc5d546218"; final JobManifestLocation manifestLocation = new JobManifestLocation() .withObjectArn(manifestObjectArn) .withETag(manifestObjectVersionId); final JobManifestSpec manifestSpec = new JobManifestSpec().withFormat(JobManifestFormat.S3InventoryReport_CSV_20161130); final JobManifest manifestToPublicApi = new JobManifest() .withLocation(manifestLocation) .withSpec(manifestSpec); final String jobReportBucketArn = "arn:aws:s3:::example-report-bucket"; final String jobReportPrefix = "example-job-reports"; final JobReport jobReport = new JobReport() .withEnabled(true) .withReportScope(JobReportScope.AllTasks) .withBucket(jobReportBucketArn) .withPrefix(jobReportPrefix) .withFormat(JobReportFormat.Report_CSV_20180820); final String lambdaFunctionArn = "arn:aws:lambda:us-west-2:123456789012:function:example-function"; final JobOperation jobOperation = new JobOperation() .withLambdaInvoke(new LambdaInvokeOperation().withFunctionArn(lambdaFunctionArn)); final S3Tag departmentTag = new S3Tag().withKey("department").withValue("Marketing"); final S3Tag fiscalYearTag = new S3Tag().withKey("FiscalYear").withValue("2020"); final String roleArn = "arn:aws:iam::123456789012:role/example-batch-operations-role"; final Boolean requiresConfirmation = true; final int priority = 10; final CreateJobRequest request = new CreateJobRequest() .withAccountId("123456789012") .withDescription("Test lambda job") .withManifest(manifestToPublicApi) .withOperation(jobOperation) .withPriority(priority) .withRoleArn(roleArn) .withReport(jobReport) .withTags(departmentTag, fiscalYearTag) .withConfirmationRequired(requiresConfirmation); final CreateJobResult result = awss3ControlClient.createJob(request); return result.getJobId(); }