AWS SDK 또는 CLI와 함께 GetBucketReplication 사용 - AWS SDK 코드 예제

AWS SDK 예제 GitHub 리포지토리에 더 많은 AWS문서 SDK 예제가 있습니다.

AWS SDK 또는 CLI와 함께 GetBucketReplication 사용

다음 코드 예시는 GetBucketReplication의 사용 방법을 보여 줍니다.

CLI
AWS CLI

다음 명령은 amzn-s3-demo-bucket이라는 버킷의 복제 구성을 가져옵니다.

aws s3api get-bucket-replication --bucket amzn-s3-demo-bucket

출력:

{ "ReplicationConfiguration": { "Rules": [ { "Status": "Enabled", "Prefix": "", "Destination": { "Bucket": "arn:aws:s3:::amzn-s3-demo-bucket-backup", "StorageClass": "STANDARD" }, "ID": "ZmUwNzE4ZmQ4tMjVhOS00MTlkLOGI4NDkzZTIWJjNTUtYTA1" } ], "Role": "arn:aws:iam::123456789012:role/s3-replication-role" } }
Java
SDK for Java 2.x
참고

GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

/** * Retrieves the replication details for the specified S3 bucket. * * @param s3Client the S3 client used to interact with the S3 service * @param sourceBucketName the name of the S3 bucket to retrieve the replication details for * * @throws S3Exception if there is an error retrieving the replication details */ public static void getReplicationDetails(S3Client s3Client, String sourceBucketName) { GetBucketReplicationRequest getRequest = GetBucketReplicationRequest.builder() .bucket(sourceBucketName) .build(); try { ReplicationConfiguration replicationConfig = s3Client.getBucketReplication(getRequest).replicationConfiguration(); ReplicationRule rule = replicationConfig.rules().get(0); System.out.println("Retrieved destination bucket: " + rule.destination().bucket()); System.out.println("Retrieved priority: " + rule.priority()); System.out.println("Retrieved source-bucket replication rule status: " + rule.status()); } catch (S3Exception e) { System.err.println("Failed to retrieve replication details: " + e.awsErrorDetails().errorMessage()); } }
PowerShell
Tools for PowerShell V4

예제 1: 이름이 'amzn-s3-demo-bucket'인 버킷에 설정된 복제 구성 정보를 반환합니다.

Get-S3BucketReplication -BucketName amzn-s3-demo-bucket
  • API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조(V4)GetBucketReplication을 참조하세요.

Tools for PowerShell V5

예제 1: 이름이 'amzn-s3-demo-bucket'인 버킷에 설정된 복제 구성 정보를 반환합니다.

Get-S3BucketReplication -BucketName amzn-s3-demo-bucket
  • API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조(V5)GetBucketReplication을 참조하세요.