AWS SDK for .NET을 사용하여 Amazon S3 Glacier의 볼트 알림 구성 - Amazon S3 Glacier

Amazon Simple Storage Service(S3)의 아카이브 스토리지를 처음 사용하는 경우, 먼저 Amazon S3의 S3 Glacier 스토리지 클래스, S3 Glacier Instant Retrieval, S3 Glacier Flexible RetrievalS3 Glacier Deep Archive에 대해 자세히 알아보는 것을 권장합니다. 자세한 내용은 Amazon S3 사용 설명서의 S3 Glacier 스토리지 클래스 및 객체 보관용 스토리지 클래스를 참조하십시오.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK for .NET을 사용하여 Amazon S3 Glacier의 볼트 알림 구성

다음은 AWS SDK for .NET의 저레벨 API를 사용해 볼트 알림을 구성하는 단계입니다.

  1. AmazonGlacierClient 클래스(클라이언트)의 인스턴스를 만듭니다.

    볼트가 속하는 AWS 리전을 지정합니다. 이 클라이언트를 사용하여 실행하는 모든 작업이 해당 AWS 리전에 적용됩니다.

  2. SetVaultNotificationsRequest 클래스 인스턴스를 생성하여 알림 구성 정보를 입력합니다.

    볼트 이름과 알림 구성 정보, 그리고 계정 ID를 입력해야 합니다. 계정 ID를 입력하지 않는 경우에는 요청 서명을 위해 입력하는 자격 증명과 연결되어 있는 계정 ID로 간주합니다. 자세한 내용은 Amazon S3 Glacier와 함께 AWS SDK for .NET 사용 섹션을 참조하세요.

    알림 구성을 지정할 때, 기존 Amazon SNS 토픽의 Amazon 리소스 이름(ARN)과 알림 메시지 수신을 원하는 한 개 이상의 이벤트를 입력합니다. 지원되는 이벤트 목록은 볼트 알림 구성 설정(PUT notification-configuration) 단원을 참조하십시오.

  3. 요청 객체를 파라미터로 입력하여 SetVaultNotifications 메서드를 실행합니다.

  4. 볼트 알림 구성을 설정한 후에는 GetVaultNotifications 메서드를 호출하여 구성 정보를 가져오거나, 혹은 클라이언트에서 제공하는 DeleteVaultNotifications 메서드를 호출하여 제거할 수 있습니다.

예제: AWS SDK for .NET을 사용하는 볼트의 알림 구성 설정

다음은 앞선 단계에서 설명한 작업을 실행하는 C# 코드 예제입니다. 예시에서는 미국 서부(오레곤)에 속한 볼트(‘examplevault‘)의 알림 구성을 설정하고 검색한 후 삭제합니다. ArchiveRetrievalCompleted 이벤트 또는 InventoryRetrievalCompleted 이벤트가 발생할 경우 구성에 따라 Amazon S3 Glacier(S3 Glacier)가 지정된 Amazon SNS 토픽에 알림 메시지를 전송하도록 요청합니다.

참고

기본 REST API에 대한 자세한 내용은 볼트 작업 단원을 참조하십시오.

다음 예제를 실행하기 위한 단계별 지침은 코드 예제 실행 섹션을 참조하세요. 예시와 같이 코드를 업데이트한 후 기존 볼트 이름과 Amazon SNS 토픽을 입력해야 합니다.

using System; using System.Collections.Generic; using Amazon.Glacier; using Amazon.Glacier.Model; using Amazon.Runtime; namespace glacier.amazon.com.docsamples { class VaultNotificationSetGetDelete { static string vaultName = "examplevault"; static string snsTopicARN = "*** Provide Amazon SNS topic ARN ***"; static IAmazonGlacier client; public static void Main(string[] args) { try { using (client = new AmazonGlacierClient(Amazon.RegionEndpoint.USWest2)) { Console.WriteLine("Adding notification configuration to the vault."); SetVaultNotificationConfig(); GetVaultNotificationConfig(); Console.WriteLine("To delete vault notification configuration, press Enter"); Console.ReadKey(); DeleteVaultNotificationConfig(); } } catch (AmazonGlacierException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("To continue, press Enter"); Console.ReadKey(); } static void SetVaultNotificationConfig() { SetVaultNotificationsRequest request = new SetVaultNotificationsRequest() { VaultName = vaultName, VaultNotificationConfig = new VaultNotificationConfig() { Events = new List<string>() { "ArchiveRetrievalCompleted", "InventoryRetrievalCompleted" }, SNSTopic = snsTopicARN } }; SetVaultNotificationsResponse response = client.SetVaultNotifications(request); } static void GetVaultNotificationConfig() { GetVaultNotificationsRequest request = new GetVaultNotificationsRequest() { VaultName = vaultName, AccountId = "-" }; GetVaultNotificationsResponse response = client.GetVaultNotifications(request); Console.WriteLine("SNS Topic ARN: {0}", response.VaultNotificationConfig.SNSTopic); foreach (string s in response.VaultNotificationConfig.Events) Console.WriteLine("Event : {0}", s); } static void DeleteVaultNotificationConfig() { DeleteVaultNotificationsRequest request = new DeleteVaultNotificationsRequest() { VaultName = vaultName }; DeleteVaultNotificationsResponse response = client.DeleteVaultNotifications(request); } } }