AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-10-01 · Documentation low

File: code-library/latest/ug/s3-control_example_s3-control_CreateJob_section.md

Summary

Added Python SDK example for creating S3 batch jobs with tagging and reporting configuration

Security assessment

The change adds a code example for batch job creation but does not address any specific security vulnerability or weakness. While it includes tagging and reporting features, these are standard operational aspects rather than security fixes.

Diff

diff --git a/code-library/latest/ug/s3-control_example_s3-control_CreateJob_section.md b/code-library/latest/ug/s3-control_example_s3-control_CreateJob_section.md
index 8250d17c0..061af90de 100644
--- a//code-library/latest/ug/s3-control_example_s3-control_CreateJob_section.md
+++ b//code-library/latest/ug/s3-control_example_s3-control_CreateJob_section.md
@@ -420,0 +421,87 @@ Create a new governance retention job.
+Python
+    
+
+**SDK for Python (Boto3)**
+    
+
+###### Note
+
+There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/s3/scenarios/batch#code-examples). 
+    
+    
+        def create_s3_batch_job(self, account_id: str, role_arn: str, manifest_location: str,
+                               report_bucket_name: str) -> str:
+            """
+            Create an S3 batch operation job.
+    
+            Args:
+                account_id (str): AWS account ID
+                role_arn (str): IAM role ARN for batch operations
+                manifest_location (str): Location of the manifest file
+                report_bucket_name (str): Bucket for job reports
+    
+            Returns:
+                str: Job ID
+    
+            Raises:
+                ClientError: If job creation fails
+            """
+            try:
+                bucket_name = manifest_location.split(':::')[1].split('/')[0]
+                manifest_key = 'job-manifest.csv'
+                manifest_obj = self.s3_client.head_object(
+                    Bucket=bucket_name,
+                    Key=manifest_key
+                )
+                etag = manifest_obj['ETag'].strip('"')
+                
+                response = self.s3control_client.create_job(
+                    AccountId=account_id,
+                    Operation={
+                        'S3PutObjectTagging': {
+                            'TagSet': [
+                                {
+                                    'Key': 'BatchTag',
+                                    'Value': 'BatchValue'
+                                },
+                            ]
+                        }
+                    },
+                    Report={
+                        'Bucket': report_bucket_name,
+                        'Format': 'Report_CSV_20180820',
+                        'Enabled': True,
+                        'Prefix': 'batch-op-reports',
+                        'ReportScope': 'AllTasks'
+                    },
+                    Manifest={
+                        'Spec': {
+                            'Format': 'S3BatchOperations_CSV_20180820',
+                            'Fields': ['Bucket', 'Key']
+                        },
+                        'Location': {
+                            'ObjectArn': manifest_location,
+                            'ETag': etag
+                        }
+                    },
+                    Priority=10,
+                    RoleArn=role_arn,
+                    Description='Batch job for tagging objects',
+                    ConfirmationRequired=True
+                )
+                job_id = response['JobId']
+                print(f"The Job id is {job_id}")
+                return job_id
+            except ClientError as e:
+                print(f"Error creating batch job: {e}")
+                if 'Message' in str(e):
+                    print(f"Detailed error message: {e.response['Message']}")
+                raise
+    
+    
+
+  * For API details, see [CreateJob](https://docs.aws.amazon.com/goto/boto3/s3control-2018-08-20/CreateJob) in _AWS SDK for Python (Boto3) API Reference_. 
+
+
+
+