AWS AmazonS3 documentation change
Summary
Replaced detailed Java SDK code example with a high-level description of lifecycle configuration management steps and added a link to API reference documentation
Security assessment
The changes involve restructuring documentation for clarity and maintainability by removing a lengthy code sample and referencing external API examples. There is no evidence of addressing security vulnerabilities, patching weaknesses, or introducing security controls. The modifications focus on improving developer experience rather than security aspects.
Diff
diff --git a/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.md b/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.md index 7fb01a94e..2b79a4977 100644 --- a//AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.md +++ b//AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.md @@ -363 +363 @@ When you add an S3 Lifecycle configuration to a bucket, Amazon S3 replaces the b -The following example shows how to use the AWS SDK for Java to add, update, and delete the Lifecycle configuration of a bucket. The example does the following: +To manage lifecycle configuration using the AWS SDK for Java, you can: @@ -365 +365,9 @@ The following example shows how to use the AWS SDK for Java to add, update, and - * Adds a Lifecycle configuration to a bucket. + * Add a Lifecycle configuration to a bucket. + + * Retrieve the Lifecycle configuration and update it by adding another rule. + + * Add the modified Lifecycle configuration to the bucket. Amazon S3 replaces the existing configuration. + + * Retrieve the configuration again and verify that it has the right number of rules by printing the number of rules. + + * Delete the Lifecycle configuration and verify that it has been deleted by attempting to retrieve it again. @@ -367 +374,0 @@ The following example shows how to use the AWS SDK for Java to add, update, and - * Retrieves the Lifecycle configuration and updates it by adding another rule. @@ -369,112 +375,0 @@ The following example shows how to use the AWS SDK for Java to add, update, and - * Adds the modified Lifecycle configuration to the bucket. Amazon S3 replaces the existing configuration. - - * Retrieves the configuration again and verifies that it has the right number of rules by printing the number of rules. - - * Deletes the Lifecycle configuration and verifies that it has been deleted by attempting to retrieve it again. - - - - -For instructions on creating and testing a working sample, see [Getting Started](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/getting-started.html) in the _AWS SDK for Java Developer Guide_. - - - import com.amazonaws.AmazonServiceException; - import com.amazonaws.SdkClientException; - import com.amazonaws.auth.profile.ProfileCredentialsProvider; - import com.amazonaws.regions.Regions; - import com.amazonaws.services.s3.AmazonS3; - import com.amazonaws.services.s3.AmazonS3ClientBuilder; - import com.amazonaws.services.s3.model.BucketLifecycleConfiguration; - import com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Transition; - import com.amazonaws.services.s3.model.StorageClass; - import com.amazonaws.services.s3.model.Tag; - import com.amazonaws.services.s3.model.lifecycle.LifecycleAndOperator; - import com.amazonaws.services.s3.model.lifecycle.LifecycleFilter; - import com.amazonaws.services.s3.model.lifecycle.LifecyclePrefixPredicate; - import com.amazonaws.services.s3.model.lifecycle.LifecycleTagPredicate; - - import java.io.IOException; - import java.util.Arrays; - - public class LifecycleConfiguration { - - public static void main(String[] args) throws IOException { - Regions clientRegion = Regions.DEFAULT_REGION; - String bucketName = "*** Bucket name ***"; - - // Create a rule to archive objects with the "glacierobjects/" prefix to Glacier - // immediately. - BucketLifecycleConfiguration.Rule rule1 = new BucketLifecycleConfiguration.Rule() - .withId("Archive immediately rule") - .withFilter(new LifecycleFilter(new LifecyclePrefixPredicate("glacierobjects/"))) - .addTransition(new Transition().withDays(0).withStorageClass(StorageClass.Glacier)) - .withStatus(BucketLifecycleConfiguration.ENABLED); - - // Create a rule to transition objects to the Standard-Infrequent Access storage - // class - // after 30 days, then to Glacier after 365 days. Amazon S3 will delete the - // objects after 3650 days. - // The rule applies to all objects with the tag "archive" set to "true". - BucketLifecycleConfiguration.Rule rule2 = new BucketLifecycleConfiguration.Rule() - .withId("Archive and then delete rule") - .withFilter(new LifecycleFilter(new LifecycleTagPredicate(new Tag("archive", "true")))) - .addTransition(new Transition().withDays(30) - .withStorageClass(StorageClass.StandardInfrequentAccess)) - .addTransition(new Transition().withDays(365).withStorageClass(StorageClass.Glacier)) - .withExpirationInDays(3650) - .withStatus(BucketLifecycleConfiguration.ENABLED); - - // Add the rules to a new BucketLifecycleConfiguration. - BucketLifecycleConfiguration configuration = new BucketLifecycleConfiguration() - .withRules(Arrays.asList(rule1, rule2)); - - try { - AmazonS3 s3Client = AmazonS3ClientBuilder.standard() - .withCredentials(new ProfileCredentialsProvider()) - .withRegion(clientRegion) - .build(); - - // Save the configuration. - s3Client.setBucketLifecycleConfiguration(bucketName, configuration); - - // Retrieve the configuration. - configuration = s3Client.getBucketLifecycleConfiguration(bucketName); - - // Add a new rule with both a prefix predicate and a tag predicate. - configuration.getRules().add(new BucketLifecycleConfiguration.Rule().withId("NewRule") - .withFilter(new LifecycleFilter(new LifecycleAndOperator( - Arrays.asList(new LifecyclePrefixPredicate("YearlyDocuments/"), - new LifecycleTagPredicate(new Tag( - "expire_after", - "ten_years")))))) - .withExpirationInDays(3650) - .withStatus(BucketLifecycleConfiguration.ENABLED)); - - // Save the configuration. - s3Client.setBucketLifecycleConfiguration(bucketName, configuration); - - // Retrieve the configuration. - configuration = s3Client.getBucketLifecycleConfiguration(bucketName); - - // Verify that the configuration now has three rules. - configuration = s3Client.getBucketLifecycleConfiguration(bucketName); - System.out.println("Expected # of rules = 3; found: " + configuration.getRules().size()); - - // Delete the configuration. - s3Client.deleteBucketLifecycleConfiguration(bucketName); - - // Verify that the configuration has been deleted by attempting to retrieve it. - configuration = s3Client.getBucketLifecycleConfiguration(bucketName); - String s = (configuration == null) ? "No configuration found." : "Configuration found."; - System.out.println(s); - } catch (AmazonServiceException e) { - // The call was transmitted successfully, but Amazon S3 couldn't process - // it, so it returned an error response. - e.printStackTrace(); - } catch (SdkClientException e) { - // Amazon S3 couldn't be contacted for a response, or the client - // couldn't parse the response from Amazon S3. - e.printStackTrace(); - } - } - } @@ -482,0 +378 @@ For instructions on creating and testing a working sample, see [Getting Started] +For examples of how to set lifecycle configuration on a bucket with the AWS SDK for Java, see [Set lifecycle configuration on a bucket](https://docs.aws.amazon.com/AmazonS3/latest/API/s3_example_s3_PutBucketLifecycleConfiguration_section.html) in the _Amazon S3 API Reference_.