Membuat tugas Operasi Batch dengan tanda pekerjaan yang digunakan untuk pelabelan - Amazon Simple Storage Service

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Membuat tugas Operasi Batch dengan tanda pekerjaan yang digunakan untuk pelabelan

Anda dapat melabeli dan mengontrol akses ke pekerjaan S3 Batch Operations Anda dengan menambahkan tag. Tag dapat digunakan untuk mengidentifikasi siapa yang bertanggung jawab atas pekerjaan Batch Operation. Anda dapat membuat pekerjaan dengan tag yang telah dilampirkan, atau menambahkan tag ke pekerjaan setelah pekerjaan dibuat. Untuk informasi selengkapnya, lihat Mengendalikan pekerjaan akses dan pelabelan menggunakan tag.

Contoh AWS CLI berikut membuat tugas S3PutObjectCopy Operasi Batch S3 menggunakan tanda tugas sebagai label untuk pekerjaan tersebut.

  1. Pilih tindakan atau OPERATION yang akan dilaksanakan oleh Batch Operations, lalu pilih TargetResource.

    read -d '' OPERATION <<EOF { "S3PutObjectCopy": { "TargetResource": "arn:aws:s3:::destination-bucket" } } EOF
  2. Identifikasi pekerjaan TAGS yang Anda inginkan untuk pekerjaan tersebut. Dalam hal ini, Anda akan menerapkan dua tag, department dan FiscalYear, masing-masing dengan nilai Marketing dan 2020.

    read -d '' TAGS <<EOF [ { "Key": "department", "Value": "Marketing" }, { "Key": "FiscalYear", "Value": "2020" } ] EOF
  3. Tentukan MANIFEST untuk pekerjaan Batch Operations.

    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. Konfigurasikan REPORT untuk pekerjaan Batch Operations.

    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. Jalankan tindakan create-job untuk membuat pekerjaan Batch Operations dengan input yang telah ditetapkan pada langkah sebelumnya.

    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";

Contoh berikut membuat tugas Operasi Batch S3 dengan tanda menggunakan AWS SDK for Java.

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(); }